Actions

Difference between revisions of "Developer Area/Core Subsystems/Page Title Template"

From Mahara Wiki

< Developer Area‎ | Core Subsystems
(Created page with "<div class="wikitext"> All templating in Mahara is done with Dwoo ([http://dwoo.org/ <span style="white-space: nowrap">Image:http.pnghttp://dwoo.org/</span>]). Each page tha…")
 
(Undo revision 13707 by Anitsirk (talk))
Tag: Undo
 
(8 intermediate revisions by 4 users not shown)
Line 2: Line 2:
  
 
All templating in Mahara is done with Dwoo ([http://dwoo.org/ <span style="white-space: nowrap">[[Image:http.png]]http://dwoo.org/</span>]). Each page that requires templating (which should be all pages that return HTML) will do so by fetching a smarty object via the [http://mahara.eduforge.org/api/mahara/core/_lib---web.php.html#functionsmarty <span style="white-space: nowrap">[[Image:http.png]]smarty()</span>] function (in lib/web.php).
 
All templating in Mahara is done with Dwoo ([http://dwoo.org/ <span style="white-space: nowrap">[[Image:http.png]]http://dwoo.org/</span>]). Each page that requires templating (which should be all pages that return HTML) will do so by fetching a smarty object via the [http://mahara.eduforge.org/api/mahara/core/_lib---web.php.html#functionsmarty <span style="white-space: nowrap">[[Image:http.png]]smarty()</span>] function (in lib/web.php).
 +
 +
Usually, the smarty() function is called to generate an entire html page, and smarty_core() to generate a fragment.  When you have a page that needs to include forms built with pieform() (see [[Developer_Area/Core_Subsystems/Form_API_(Pieforms)]]), you should try to build all the forms before calling smarty().  Failure to do this can result in some javascript required by form elements not being included.
  
 
<div id="section_1">
 
<div id="section_1">
  
=== Template Locations ===
+
===Template Locations===
  
 
The smarty object returned searches for templates in /theme//templates/ where  starts at the current theme, and walks up parents until it finds a file (or a theme with no parent and no file causing an error).
 
The smarty object returned searches for templates in /theme//templates/ where  starts at the current theme, and walks up parents until it finds a file (or a theme with no parent and no file causing an error).
Line 17: Line 19:
 
</div><div id="section_2">
 
</div><div id="section_2">
  
=== Template variables ===
+
===Template variables===
  
 
The following variables are set by the smarty() function for every page and template.
 
The following variables are set by the smarty() function for every page and template.
  
* '''THEMEURL'''<nowiki>: The base url for static content</nowiki>
+
* '''THEMEURL''': The base url for static content
* '''WWWROOT'''<nowiki>: The base url for the mahara system</nowiki>
+
* '''WWWROOT''': The base url for the mahara system
* '''USER'''<nowiki>: The user object</nowiki>
+
* '''USER''': The user object
* '''JAVASCRIPT'''<nowiki>: A list of javascript files to include in the header. This list is passed into this function (see below).</nowiki>
+
* '''JAVASCRIPT''': A list of javascript files to include in the header. This list is passed into this function (see below).
* '''HEADERS'''<nowiki>: An array of any further headers to set. Each header is just straight HTML (see below).</nowiki>
+
* '''HEADERS''': An array of any further headers to set. Each header is just straight HTML (see below).
* '''PUBLIC'''<nowiki>: Set true if this page is a public page</nowiki>
+
* '''PUBLIC''': Set true if this page is a public page
* '''MAINNAV'''<nowiki>: Array defining the main navigation</nowiki>
+
* '''MAINNAV''': Array defining the main navigation
  
 
</div><div id="section_3">
 
</div><div id="section_3">
  
=== Template functions ===
+
===Template functions===
  
 
The following functions are available for every page and template.
 
The following functions are available for every page and template.
Line 37: Line 39:
 
<div id="section_4">
 
<div id="section_4">
  
==== str ====
+
====str====
  
 
str is a custom function that looks up tags and returns an internationalised string.
 
str is a custom function that looks up tags and returns an internationalised string.
  
 
{| class="wiki-dl-table" border="1" cellpadding="6"
 
{| class="wiki-dl-table" border="1" cellpadding="6"
|- class="tightenable bottom"
+
|-
 
! Attribute Name
 
! Attribute Name
 
! Type
 
! Type
Line 48: Line 50:
 
! Default
 
! Default
 
| '''Description'''
 
| '''Description'''
|- class="tightenable top bottom"
+
|-
 
! tag
 
! tag
 
! String
 
! String
Line 54: Line 56:
 
! n/a
 
! n/a
 
| The tag to look up.
 
| The tag to look up.
|- class="tightenable top bottom"
+
|-
 
! section
 
! section
 
! String
 
! String
Line 60: Line 62:
 
! mahara
 
! mahara
 
| Section to look up the tag in.
 
| Section to look up the tag in.
|- class="tightenable top"
+
|-
 
! assign
 
! assign
 
! String
 
! String
Line 69: Line 71:
  
 
</div></div></div>
 
</div></div></div>
 +
[[Category:Developer Area]]

Latest revision as of 16:21, 1 June 2023

All templating in Mahara is done with Dwoo (File:Http.pnghttp://dwoo.org/). Each page that requires templating (which should be all pages that return HTML) will do so by fetching a smarty object via the File:Http.pngsmarty() function (in lib/web.php).

Usually, the smarty() function is called to generate an entire html page, and smarty_core() to generate a fragment. When you have a page that needs to include forms built with pieform() (see Developer_Area/Core_Subsystems/Form_API_(Pieforms)), you should try to build all the forms before calling smarty(). Failure to do this can result in some javascript required by form elements not being included.

Template Locations

The smarty object returned searches for templates in /theme//templates/ where starts at the current theme, and walks up parents until it finds a file (or a theme with no parent and no file causing an error).

Templates for artefacts in Mahara are accessed via a separate resource plugin. Where normal plugins are accessed just with a relative path (e.g. "mycontacts/index.tpl") artefact plugins will use their plugin name in the path (e.g. "arteface:internal:profile/index.tpl"). The template files themselves should be placed in /artefact//theme//

Also, templates for the render() method of an artefact should be placed in the 'render' subdirectory of the artefact plugin's template directory, and should follow the naming convention _.tpl

e.g., /artefact/blog/theme/default/render/blog_listchildren.tpl

Template variables

The following variables are set by the smarty() function for every page and template.

  • THEMEURL: The base url for static content
  • WWWROOT: The base url for the mahara system
  • USER: The user object
  • JAVASCRIPT: A list of javascript files to include in the header. This list is passed into this function (see below).
  • HEADERS: An array of any further headers to set. Each header is just straight HTML (see below).
  • PUBLIC: Set true if this page is a public page
  • MAINNAV: Array defining the main navigation

Template functions

The following functions are available for every page and template.

str

str is a custom function that looks up tags and returns an internationalised string.

Attribute Name Type Required Default Description
tag String Yes n/a The tag to look up.
section String No mahara Section to look up the tag in.
assign String No empty If specified, rather than putting the string inline, will put it in this variable.