Content - Functions, vars, tags, & filters


Functions

error()

Error method handler for content plugin that loads up content based on friendly url. Usually you should place the error method handler in your default controller’s __error() method.

function __error($request, $optional_parameters){
	// Show content page if available
	$this->zajlib->content->error($request);
	// ...

enable_wordpress_save()

This is used to enable importing from WordPress admin.

@param callable|boolean $callback If a callback function is given, it will call with the content page object and the post object as parameters.

Have a look at previous projects for some examples.

Variables

Variables in the content plugin are under the {{content}} scope. The following are available:

  • {{content.contentpage}} – the current ContentPage object. Available on all contentpage templates. Although it is also available in contentpagesection templates, you should try to make your contentpagesection templates independent of this variable and user {{content.contentpagesection.data.contentpage}} instead.
  • {{content.contentpagesection}} – the current ContentPageSection object. Available in all contentpagesection templates.
  • {{content.contentmenu}} – the current ContentMenu object. Available in all contentmenu templates.
  • {{content.contentpagetypesetting}} – the current settings object. Available in list and page templates.

Tags

contentpagesections

Displays one or more content sections within the current content page.

@param column_number – optional – The column number. If omitted, it will display all sections in all columns.
@param item_number – optional – The 1-based index of the section in the column. If ommitted, all sections in the column will be displayed.
@param fallback – optional – You can specify a custom template to display if the requested section (or sections) is/are not available.

Display the all sections:

{% contentpagesections %}

Display the 2nd column:

{% contentpagesections 2 %}

Display the 3rd item in the 2nd column:

{% contentpagesections 2 3 %}

Display the 3rd item in the 2nd column, and if none exists, fall back to the template:

{% contentpagesections 2 3 'contentpagesection/_fallback.html' %}

Display the 2nd column, and if no sections are in it, fall back to the template:

{% contentpagesections 2 false 'contentpagesection/_fallback.html' %}

contentpagesection

Display a specific content page section by object or id. Be careful to not mix it up with the plural version above!

@param contentpagesection – required – the id or the ContentPageSection object.

You can pass an id directly:

{% contentpagesection 'id' %}

Or you can pass a variable which contains the id or the object:

{% contentpagesection section %}

contentmenu

Displays a particular content menu.

@param menu_type – required – the type as defined in the content.conf.ini / contentmenu_types.
@param template – optional – use this custom template instead of contentmenu/_type_name.html or contentmenu/_default.html.

Display the main menu:

{% contentmenu 'mainmenu' %}

Display the main menu with a custom template:

{% contentmenu 'mainmenu' 'contentmenu/_mainmenu_alternate.html' %}

Filters

|column

Filter sections down to a specific column.
@param column_number – required – the column number to filter down to.

Filter sections down to only column 2:

{% foreach content.contentpage.data.contentpagesections|column:2 as cps %}
...
Outlast Web & Mobile Development (c) 2023 | Privacy Policy |