Template Library

The template library powers all out the output on the PyroCMS public and admin pages. The template is auto-loaded, so there is no need to load it in your controllers.

Method Reference

title($title1, [$title2, $title3, …])

Sets the title of the page. You can send as many title parameters as you'd like, although the first one is required. Your titles will be imploded with the title string separator.

$this->template->title('The Current Page');

build($view, [$data])

The build function is what builds the output for the browser in PyroCMS and is used in lieu of simply loading a view. It will take the theme data, layout, and build those elements automatically, so your view file only needs to contain the actual page content.

$this->template->build('form', $this->data);

set($varname, $varvalue)

Sets data that can be used in your views. You can provide two strings or an array.

Two strings of data:

$this->template->set('foo', $bar);

Array of data:

$this->template->set(array('foo' => $bar, 'foo2' => $bar2));


Adds a string to the start of the auto-generated metadata output.

$this->template->prepend_metadata('<script src="/js/jquery.js"></script>');


Adds a string to the end of the auto-generated metadata output.

$this->template->append_metadata('<script src="/js/jquery.flot.js"></script>');


Allows you to set a layout from your your_theme/views/layouts folder.

// This will use your_theme/views/layouts/two_col.html
// as the page layout.

Note: When using Public_Controller and Admin_Controller, the layout is already set. However, in some cases, you may prefer to override this function or use set a layout outside of the PyroCMS base controllers.


Allows you to set a theme.


Note: As with set_layout, the theme is already set when extending either the Public_Controller and Admin_Controller.


This allows you to enable the PyroCMS Lex tag parser. When the tag parser is off, PyroCMS tags will not work in your views.



Enables/disables the minification of assets added via the template library.



Returns the path of the current theme.


The template library methods are frequently chained in PyroCMS, so you may see the functions called like this:

    ->title($this->module_details['name'], lang('keywords:add_title'))
    ->set('keyword', $keyword)
    ->build('admin/form', $this->data);