Developer Area/HowToWriteAViewTemplate

From Mahara Wiki

< Developer Area
Revision as of 16:14, 11 May 2011 by WikiSysop (talk | contribs)

Mahara will look in DATAROOT/templates and LIBROOT/templates. Each template should live in its own subdirectory within either of these two locations. Mahara will give preference to templates in DATAROOT over LIBROOT, as this will allow customising templates.

Each subdirectory must contain two files:


Additionally, it is recommended to also include:


Config.php is a small amount of php to describe the template, like so:

 $template->title = 'Example template';
 $template->description = 'Very rough proof of concept example template';
 $template->category = 'resume'; (see ViewTemplateCategories?)


fragment.template is a fragment of HTML with some extra tags to designate blocks. The HTML should contain everything up to and not including


The tags to designate blocks look like so:

{{block type="" format="" id="" width="" height="" defaulttype="" defaultformat=""}}

the id attribute is the only one that is required.

width and height are optional, and if given, whatever is dropped into these blocks must somehow fit itself to these constraints.

type/defaulttype are optional and correspond to the name of an artefact type.

format/defaultformat are optional and are one of:

label listself listchildren renderfull rendermetadata

These types are discussed in ViewTemplates.

Types and formats cannot be given without eachother.

fragment.css is a snippet of css that will be inserted into the view.

thumbnail.(jpg|jpeg|gif|png) is the thumbnail to display to the user in the template selection screen of Create View