Question

I've read the Add a New Custom Page to phpBB guide several times, but still can't get this to work.

I'm trying to integrate this calendar with phpBB3. I want the calendar code to have access to phpBB variables, so it will only let registered users add new events.

The phpBB guide above recommends creating a short PHP page, which sets up the phpBB session and then calls a static HTML template, that uses Server Side Includes (SSI) to pull in phpBB headers, etc. But my calendar page is not just static HTML, it also includes PHP code. I can't get the calendar page's PHP output to display inbetween the phpBB header and footer. The calendar's HTML appears correctly, but no PHP gets executed. It appears that the recommended method simply does not allow PHP code to be executed in the template.

To summarise: I followed the guide above, but replaced 'aboutus_body.html' with my 'calendar.php'. Instead of seeing the calendar displayed correctly, with phpBB header and footer, I only saw the HTML parts of calendar.php displayed with phpBB header and footer. No calendar PHP output was visible.

Was it helpful?

Solution

Okay I've understood the correct way to do this now:

After following the tutorial at: http://wiki.phpbb.com/Practical.Add_custom_page

Copy all the calendar code into aboutus.php (in the tutorial, the php file where the phpBB session is set up, and the URL by which the page will be accessed), before the $template->set_filenames line

But the key is: instead of outputting the HTML with 'print' or 'echo', save all the HTML in a variable, e.g. $calendar_html

Then when you've finished building the page, use this code before the $template->set_filenames line:

$template->assign_vars(array(
    'CALENDAR_HTML' => $calendar_html,
   )
);

Then in the template (aboutus_body.html in the tutorial), load the variable like this:

{CALENDAR_HTML}

...in place of the HTML content.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top