-
Notifications
You must be signed in to change notification settings - Fork 32
TemplateDocumentation
This page is incomplete at the moment, but it will hopefully soon document everything designers need to know when making custom Phorum templates.
For every page, the header.tpl is sent first. After that, a specific template for the page that is handled is sent. After that, the footer.tpl is sent. These three are always sent in three separate calls in the Phorum core (take a look at some php's to see this happen).
Here's an overview of the template files in the default template. I've tried to make a little bit of a categorization to make things more clear.
GENERIC TEMPLATES:
footer.tpl The footer that is put at the end of every page
header.tpl The header that is put at the start of every page
message.tpl A generic block for displaying messages
paging.tpl A generic block for adding paging navigation to a page
stdblock.tpl A generic block with a title and content part. I think this
one is now only used by pm.php and could be phased out
by using message.tpl instead.
ENTRYPOINT TEMPLATES:
cc_index.tpl The user control center, this one loads other cc_* files
index_new.tpl New style forum overview
index_classic.tpl Classic forum overview
follow.tpl When the user wants to follow a thread
list.tpl Flat view message list
list_threads.tpl Threaded view message list
login.tpl The login page
pm.tpl The private messages system, this one loads other pm_* files
posting.tpl The message editor, this one loads other posting_* files
profile.tpl For displaying a user's profile (the public one, not from CC)
read.tpl Flat view message reading
read_threads.tpl Threaded view message reading
register.tpl For registering a new account
merge_form.tpl (moderation) Merge two threads
move_form.tpl (moderation) Move a thread to another forum
split_form.tpl (moderation) Split a thread in two threads
Phorum uses its own template programming language to allow dynamic templates without using PHP.
Variable Substitution:
Any variable currently available to Phorum in $PHORUM['DATA']
can be output in a template page by means of the '''{VAR}''' syntax. eg: '''{NAME}''' will output the current forum name.
Array variables may be accessed via the '''{ARRAY_NAME->VAR}''' syntax. eg: '''{LANG->Email}''' accesses the language array, to output the language "Email" in the current language.
You can check which variables are available in a page with this code:
<?php print_var($PHORUM['DATA']);?>
Just put it in your template and it will show you the available data.
'''Conditional Output, IF...ELSE statements:'''
The syntax for conditional output is:
{IF <condition>}
Output Text
{/IF}
eg:
{IF NAME}
Forum Name: {NAME}
{/IF}
In the above example, we are testing to see if {NAME} (the current forum name) exists. For example, when seeing a list of all forums, it would not be set. If it does exist, we would output "Forum Name: {NAME}" where {NAME} would be substituted by the forum's name.
IF...ELSE statments are also supported:
{IF PROFILE->signature}
{PROFILE->signature}
{ELSE}
You don't have a signature set
{/IF}
Conditional statements can also check the value of a variable compared to a number, a string or another template variable:
{IF VAR "a string with spaces"}
{IF MESSAGE->message_id MESSAGE->thread} <-- is this the thread starter
{IF PAGES->page_no CURRENTPAGE}<-- is this the current page
IF...ELSEIF...ELSE syntax :
{IF VAR "value one"} Output 1
{ELSEIF VAR 2} Output 2
{ELSE} Output 3
{/IF}
NOT is also supported (wasn't that 5.1 only???):
{IF NOT TOTALPAGES 1}
Sometimes, you may need the power of PHP to achieve what you need in your templates. The good news is that you can break into PHP at any point. Just use the normal syntax.
To be added - a link to a new page listing all arrays and variables available to template designers {TemplateVariables}
Also: (comment by user): ... and why not have a list with all characteristics and a screenshot with arrows to the characteristics on the forum screen ?