Howto: Include php files in phpMyFAQ

In this board you can talk about general questions about phpMyFAQ

Moderator: Thorsten

Post Reply
Thorsten
Posts: 15749
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Howto: Include php files in phpMyFAQ

Post by Thorsten »

Hello,

here a small Howto for those, which want to build PHP files into phpMyFAQ. This is not so trivial, because a simple include() functions only displays the parsed php file completely at the beginning. The reason for this is our Template engine.

First we write a PHP file, which we want to include.

Code: Select all

<?php print "Das Datum: ".date("d.m.Y"); ?>
Save this file as i.e. test.php.

Next we insert a substitute symbol {TEST} in the template file index.html to the place, where our PHP file is to be inserted.

In order to communicate phpMyFAQ that the Template engine also parses the new variable, a little more must be changed.

Add the following code before the range with "/* Einzel-Templates der Unterseiten bestimmen */" in the index.php:

Code: Select all

$string = join ("", @file("test.php"));
ob_start();
eval(" ?>".$string."<?php ");
$value = ob_get_contents();
ob_end_clean();
Into the range of the variable assignment of the templates still the variable must be registered:

Code: Select all

				"userOnline" => userOnline(),
				"TEST" => $value,
				"copyright" => 'powered by <a href="http://www.phpmyfaq.de" target="_blank">phpMyFAQ</a> '.$version.'' ));
The line "TEST" => $value, was added.

Now the file test.php is included into the FAQ and the PHP code in this file will be executed.

bye
Thorsten
Last edited by Thorsten on Fri Mar 11, 2005 8:01 am, edited 1 time in total.
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
spottedhaggis
Posts: 30
Joined: Fri Aug 20, 2004 11:26 am
Location: kent,uk

Post by spottedhaggis »

I have tried this but it does not work. I get the following at the top of the page

Warning: join(): Bad arguments. in /usr/local/4admin/apache/vhosts/ifseurope.net/httpdocs/technical/kb2/index.php on line 204

This references your above input?
Post Reply