An alternative to webtrees’ FAQ module

In a recent forum post on webtrees.net a member asked “Would it be feasible to have section headers in the FAQ?

The short answer I gave was “no, it is not currently possible, and given the generally low use of FAQs, it is not likely to be a priority to develop such a change“.

However I do think the idea has some merit.

I have mixed views on FAQs myself. I firmly believe they are rarely used or read, but at least if they exist they do provide somewhere to point people to rather than keep repeating the same advice.  So rather than suggest a significant change to webtrees, I suggested that perhaps there is a suitable already-existing software that could achieve the same goal.

Looking around the web I found phpMyFAQ. It is a very comprehensive FAQ tool, written in php, using a MySQL database, and is open source. In other words, a near perfect match for webtrees! Those features also make it a great fit for webtrees’ stated aim “… to be efficient and effective by using the right combination of third-party tools, design techniques and open standards“. (stated on the Home page of webtrees.net).

So I have started to develop a way, or ways, to utilise “pMF” in webtrees, without requiring major programming effort. On this page I aim to talk about what I have found and the solutions I have tried. At the same time I am amending my own Our Families site to use pMF. Once completed I will publish the solutions, and if necessary a module to help. Feel free to comment here if you have any thoughts on the issues raised.

Progress report 1

To start I will list some of the problems involved in using pMF in webtrees  Not, I must stress, because there is anything wrong with pMF, but to document some things that do need considering in this situation.

  1. pMF is currently in the midst of a major upgrade. The current stable release is version 2.7.9, but it’s replacement, 2.8.0, is close to release, and is quite significantly different (better from what I can see). Therefore all my development is based on 2.8.0.
  2. pMF has it’s own comprehensive user management system. Because I intend avoiding any major programming, and in particular any hacking of pMF’s code, I will be ignoring that aspect completely, with the sole exception of a single admin user necessary to create and edit FAQs.
  3. pMF 2.8.0 makes extensive use of ‘bootstrap’ styling and css. This is great for pMF, but not currently practical for webtrees. So styling will be different. I expect this will result in two or perhaps three alternative levels of integration, with the simplest being just linking to a default pMF installation and the most complex being a custom theme to match one or more of the webtrees themes (and / or simpl_themes).
  4. A major design aspect to pMF’s functionality is the ability of members / users to add their own questions, to which an administrator can add answers, creating a full FAQ. Without  using pMF’s user database, webtrees will not have access to that part of the system. All FAQs will need to be entered by a single webtrees admin, or group of webtrees users manually added to pMF. But that is no different to the standard webtrees FAQ module, so should not be a major issue.

That will do as a list for now. I’m sure there will be more as I progress. I do already have pMF operational on Our Families, but not yet to a stage where I can make it visible to guests. I can however report that it was very straightforward to install, with many similarities in both requirements and set up process to webtrees. It certainly more than satisfies the original request “…to have section headers in the FAQ…”. So at this stage it is looking good 🙂

I will add more soon.

Using simpl_menu and keeping pages within webtrees’ framwork

As I browse webtrees sites I’m always pleased to find people using the “simpl_menu” module. Its a great way to introduce other pages or software products into your family history site. Examples I’ve seen include blogging software and gallery products like Gallery2.

But, I do think many people are missing a great opportunity to maintain a sense of continuity within their webtrees site. Of course this might be by choice, and that’s fine, but I wonder if sometimes it is because users are not aware they can link to external pages AND keep them within the webtrees menu structure. For a simple example of what I am talking about, go to my Our Families site. Select Other -> My tools. That is a menu created with simpl_menu linking to a basic HTML page saved to the webtrees root directory.

The ‘trick’ to keeping that page within the webtrees structure is in its header:

<?php
define('WT_SCRIPT_NAME', 'simpl_utilities.php');
require './includes/session.php';
require_once WT_ROOT.'library/WT/Controller/Base.php';
global $controller;
$controller=new WT_Controller_Page();
$controller
	->setPageTitle(WT_I18N::translate('Utility tools'))
	->pageHeader();
echo '<h2>', WT_I18N::translate('Utility tools'), '</h2>';
?>

Everything below that is just normal HTML, and (in this case) some javascript. But you can add whatever you want, and of course adjust the text in that snippet to suit your needs.

That works fine for a simple HTML page, but what if you want to embed Gallery2, or a forum like phpBB? The answer to that is to take a leaf out of Joomla’s book, and use what they term a “wrapper”, better known as an iframe. This exists for just such a purpose, to embed an external web page within an existing framework.

There are a some things to consider with this approach though:

  1. If such products require their own login, I recommend disabling it. Manage access via webtrees’ module administration for simpl_menu setting access to members only if you don’t want casual visitors to see the page.
  2. If you want those products to blend seamlessly with your webtrees site you will need to adapt their theme to match your preferred webtrees one. That is generally not hard to do, but can take time to perfect. I also suggest in such cases that you do NOT allow your users to switch between different webtrees themes. Select your default, and fix it at that.
  3. One of the greatest drawbacks with iframes is controlling their dimensions. It’s easy enough with css to ensure the width if the frame fits your site correctly, but the height can be tricky, as the height of the content can vary from page to page. But there are solutions, such as the one described below.

Managing the height of iframes

Typically in products like Joomla the solution is to set a height greater than the maximum you think you will ever need. But that can push your webtrees’ footer so far down an empty page no-one ever sees it! Alternatively, if you set the height too short, you will get an ugly vertical scroll bar, or perhaps even two if your webtrees page needs one of its own!

What is needed is a dynamic height that automatically adjusts as the content of the iframe changes. Fortunately webtrees includes the full jQuery library, making exactly such a solution possible. If you Google the issue your will find a number of solutions. The one I prefer, and have fully tested in webtrees is below here, shown as additional code on the same header described above. This is taken from a solution I am developing to include the great FAQ software phpMyFAQ.

<?php
define('WT_SCRIPT_NAME', 'phpmyfaq.php');
require './includes/session.php';
$controller=new WT_Controller_Page();
$controller
	->setPageTitle(WT_I18N::translate('FAQs'))
	->pageHeader()
	->addInlineJavascript('
		var iFrames = document.getElementsByTagName("iframe");
		function iResize() {
			iFrames.style.height = iFrames.contentWindow.document.body.offsetHeight + "px";
		}
		jQuery("iframe").load(function() {
			this.style.height = this.contentWindow.document.body.offsetHeight + "px";
		});
	');
?>
<iframe id="myFrame" src="phpmyfaq/index.php" width="98%" scrolling="no" frameborder="0" style="width:100%;"></iframe>