Since “finalising” the method of incorporating phpMyFAQ into webtrees I have been giving more thought to some of the components of pMF that I removed as part of the style and layout changes.
A couple of them could possibly be more useful than I had thought, so here I will explain how to put them back.
Also, I will use this post to list and discuss any ideas you or I might have for other improvements. Just add a quick comment here describing how you think the integration of pMF into webtrees could be improved, and I’ll see if it can be accommodated.
This is in fact a topic already discussed under comments to the 4th article, but I thought I would add it here as well, in case it gets lost among other comments there.
Because we are displaying pMF in an iframe inside the webtrees page, we need to somehow transfer the language selected in webtrees across to the pMF code. I discovered it is in fact quite easy.
If you have followed all the previous articles, you will have created a file called phpmyfaq.php or similar in the root of your webtrees folder. This is the file you link the simpl_menu module to. In that file the last two lines will be similar to:
<iframe id="myFrame" src="phpmyfaq/index.php" width="98%" scrolling="no" frameborder="0" style="width:100%;"></iframe>
Just replace those two with these three:
$lang=substr(WT_LOCALE, 0, 2);
echo '<iframe id="myFrame" src="phpmyfaq/index.php?lang='. $lang .'" width="98%" scrolling="no" frameborder="0" style="width:100%;"></iframe>';
That takes the language from webtrees, reduces it to the 2-character form pMF uses, and then translates the pMF page to the same language. There are two issues to consider though:
- It is possible that not all the same languages are available in both products. If the webtrees language does not exist in pMF it will default to English.
- You will need to create your own language versions of each FAQ in pMF. Refer to the pMF documentation for how to do that.
pMF menu options
By removing the header section of pMF, necessary (in my opinion) to avoid too many menu structures, we lost the following options: Instant Response; Add a new FAQ, Add question, Open questions, Administration, Login.
Of these, Administration was covered, by using a second menu item in simpl_ menu, covered in the 3rd article in this series; Login cannot be used without a complex single-authority sign on system across webtrees and pMF which is beyond the scope of this project (and my abilities); and Instant Response is a variant of the Search option so not, in my opinion, an essential component.
The remaining three, might however be of use to some of you. Putting these back is easily done in just two steps:
- Create a copy/new version of the root file “phpmyfaq.php” (as created in part two of this series). Call this one something like phpmyfaq_ask.php, or phpmyfaq_add.php or phpmyfaq_open.php. You might even decide to add all three.
- Create a new menu item in simpl_menu for each of these new files, and set it’s permissions appropriately. I recommend you set these to “show to members” or higher. Allowing public access to these is likely to result in considerable spam, even if you use pMF’s “captcha” option.
For myself, I think I will only need the “Add question” option, so will explain the changes to the new phpmyfaq_ask.php file for that one. The others will be similar, but with slightly different “action” code, as you will see. If you created the new file from a copy of phpmyfaq.php, then near the end you will have something like this line:
echo '<iframe id="myFrame" src="faq2.8/index.php?lang='. $lang .'" width="98%" scrolling="no" frameborder="0" style="width:100%;"></iframe>';
To this just add “&action=ask” inside, like this:
echo '<iframe id="myFrame" src="faq2.8/index.php?lang='. $lang .'&action=ask" width="98%" scrolling="no" frameborder="0" style="width:100%;"></iframe>';
That is the main change, but to be correct you should also change these (highlighted) lines at the top of the file to this (or similar for other variants):
That all there is to it. I did however also go to pMF’s configuration (under “spam protection”) and disabled “captcha” as I don’t feel it is necessary for registered members who are already logged in. If you want to add “Add a new FAQ” use instead “&action=add”, and for the list of open questions use “&action=open”.
Now your site members can add their own questions to the FAQ pages, which you can review, answer, and publish if you wish.