|
|
Templating system in FrontPage
Background
In FrontPage, every context is associated with a template. The template defines:
- in the module administration, the areas where the FrontPage blocks can be inserted, and their visual appearance
- the display of the selected blocks in the user interface
A template is encapsulated in a directory situated in "templates/<lang>/user". The template description is contained in the file frontpage.info.php in this directory. This php file contains the definition in a hash format:
$info = array(
|
The description array must be named $info
|
'name' => 'Template'
|
The name of the template
|
'pages' => array(
|
The pages defined in this template. Each context is in fact an instance of a page. Having multiple pages in a template allows for pages that are conceptually linked (for example, the index and the detail pages) to be kept in the same place.
|
array(
|
Each page is described in it's own hash record
|
'name' => 'The main page',
|
The name of the page
|
'id' => 'index',
|
An unique id
|
'template' => 'index.html',
|
Which template will be used for display
|
'admin'=>'index-admin.html',
|
Which template is used in the administration interface
|
'thumb'=>'index-thumb.png',
|
A thumbnail version which will allow the admin a glance at how his page will look like
|
'boxes' => array(
|
The boxes that the admin can fill with the FrontPage blocks.
|
'center', 'right',
|
This array contains the ids of the blocks.
|
),
|
|
)
|
|
)
|
|
The FrontPage functions responsible for handling the templates are:
- FrontPage_userapi_getAllContextTemplates
Retrieves all available templates
- FrontPage_userapi_getContextTemplateInfo
Retrieves a template information
When a context is defined as being the implementation of a template page, the following actions take place:
- When the admin visits the context edition interface, the administration template is loaded, and the boxes defined in this template are used.
- The admin fills out the boxes with the contents present in FrontPage
- The main template is then used to display the selected contents to the user
Administration template requirements
There are a few rules to follow when creating the administration template:
- for every box defined in the "boxes" array, there must be a <div> with the id "box_$box_name".
- each box must present the contents in $entries, that have the $entry.box property set to the index of the box (0 for the first one, 1 for the second, etc.)
- each of the entries must be presented inside a <li> element, with the id $entry.iid
- each of the entries must have the following sub-elements:
- <span class="rm-handle"> (the "delete" area)
- <div class="etop-bar"> (the "drag" area)
- each of the entries should have a visual representation of $entry.lead or, if this property is not present, of $entry.text and $entry.title
Presentation template requirements
The entries are passed in this template in the $entries array. Some of the most important properties of the entries:
- $entry.box – in which box the content must be displayed (numeric index)
- $entry.srctype – the type of the content. Currently, one of:
- html - HTML content
- pi_com - Presseinfo communicate
- pi_rev - Presseinfo press review
- np - Newspaper article
- pc - procontent news
- pct - proclassified news
- $entry.title – the title of the content
- $entry.text – the text of the content
|
|
|