Source: ~/modules/cms/twig/Extension.php


  • Twig_Extension


  • Twig_ExtensionInterface

The CMS Twig extension class implements the basic CMS Twig functions and filters.

Protected properties

protected Cms\Classes\Controller $controller

A reference to the CMS controller.

Public methods

public void __construct(Cms\Classes\Controller $controller=NULL)

Creates the extension instance.


public string assetsFunction($type=NULL)

Renders registered assets of a given type

  • $type

public string componentFunction(string $name, array $parameters=array())

Renders a component's default content.

  • string $name - Specifies the component name.
  • array $parameters - A optional list of parameters to pass to the component.

public string contentFunction(string $name, array $parameters=array())

Renders a content file.

  • string $name - Specifies the content block name.
  • array $parameters - A optional list of parameters to pass to the content.

public mixed displayBlock(string $name, string $default=NULL)

Returns a layout block contents and removes the block.

  • string $name - Specifies the block name
  • string $default - The default placeholder contents.

public void endBlock($append=true)

Closes a layout block.

  • $append

public array getFilters()

Returns a list of filters this extensions provides.

public array getFunctions()

Returns a list of functions to add to the existing list.

public array getTokenParsers()

Returns a list of token parsers this extensions provides.

public string pageFilter(mixed $name, array $parameters=array(), bool $routePersistence=true)

Looks up the URL for a supplied page and returns it relative to the website root.

  • mixed $name - Specifies the Cms Page file name.
  • array $parameters - Route parameters to consider in the URL.
  • bool $routePersistence - By default the existing routing parameters will be included when creating the URL, set to false to disable this feature.

public string pageFunction()

Renders a page. This function should be used in the layout code to output the requested page.

public string partialFunction(string $name, array $parameters=array(), bool $throwException=false)

Renders a partial.

  • string $name - Specifies the partial name.
  • array $parameters - A optional list of parameters to pass to the partial.
  • bool $throwException - Throw an exception if the partial is not found.

public string placeholderFunction($name, $default=NULL)

Renders a placeholder content, without removing the block, must be called before the placeholder tag itself

  • $name
  • $default

public void startBlock(string $name)

Opens a layout block.

  • string $name - Specifies the block name

public string themeFilter(mixed $url)

Converts supplied URL to a theme URL relative to the website root. If the URL provided is an array then the files will be combined.

  • mixed $url - Specifies the theme-relative URL

Show inherited public methods

Inherited public methods

  • public void getNodeVisitors() - defined in Twig_Extension.
  • public void getOperators() - defined in Twig_Extension.
  • public void getTests() - defined in Twig_Extension.