Follow the below steps to add a new page to FUDforum. This procedure can be used to extend FUDforum, for example, to add a blog, calendar, chat page or anything else you can think off.
Contents |
Define an action by editing users.inc.t in the forum's src directory. For example, to create a page that will display Hello World, you need to add something like:
case 'hi': /* 'hi' in URL will invoke hallo.php */ $_GET['t'] = 'hallo'; break;
This will redirect index.php?t=hi (or index.php/hi/ if you are using PATH_INFO) to hallo.php.
The file hallo.php will be made up of
Create a file *.php.t in the forum's src directory that will define the page's business logic and variables. For our example, we will create src/hallo.php.t like this:
<?php /*{PRE_HTML_PHP}*/ <-- Include points /*{POST_HTML_PHP}*/ /*{POST_PAGE_PHP_CODE}*/ $msg = 'Hello world'; <-- Define code and variables ?> {TEMPLATE: HALLO_PAGE} <-- Insert HTML code
HALLO_PAGE is a PAGE template (we will defined it in the next section).
PRE_HTML_PHP, POST_HTML_PHP and POST_PAGE_PHP_CODE and be ignored for now. They define where include files (*.inc.t) will be inserted.
The visual presentation (HTML) will be defined in a template. For our example, thm/default/tmpl/hallo.tmpl will look like this:
{PHP_FILE: input: hallo.php.t; output: hallo.php;} {REF: security.tmpl} <-- include templates we may need. {REF: header.tmpl} {REF: usercp.tmpl} {REF: curtime.tmpl} {REF: footer.tmpl} {PAGE: HALLO_PAGE} <-- Define the HALLO_PAGE page. {TEMPLATE: header} <-- Use a template from an included file {TEMPLATE: usercp} <div class="ctb"> {VAR: msg} <-- Reference variable in source file </div> {TEMPLATE: curtime} {TEMPLATE: footer} {PAGE: END} <-- End of PAGE definition
Note how {VAR: msg} is used to refer to a variable in the source file (src/hallo.php.t). Similarly, {MSG: msgkey} can be used to refer to a translatable message in the forum's thm/default/i18n/en/msg file.
All that is left to do is to rebuild your theme from the Theme Manager and to test your new page.
Sorry! This site is experiencing technical difficulties.
Try waiting a few minutes and reloading.
(Can't contact the database server: Cannot return last error, no db connection)