0

Site template variable reference

Header object

header

The header object contains variables needed for building the <head> area of a HTML page.
Example: <meta name="keywords" content="{{ header.keywords }}" />

Properties

  • title
    String
    The meta title of the page, usually used in the <title> tag.
  • keywords
    String
    Meta keywords set in the site tree.
  • description
    String
    Meta description set in the site tree.
  • author
    String
    Meta author set in the site tree.
  • stylesheets
    Hash
    A hash of the stylesheets needed for the modules on the current page. The key is the path to the stylesheet file, the value is the media type. e.g. screen, print, projector.
  • javascripts
    Array
    An array of the javascript files need for the modules on the current page. Each element is the full path to the required javascript file.
  • last_modified
    Timestamp
    A timestamp representing the last time the page (or content on the page) was updated.
  • classes
    Array
    Each element in the array is a css class name which has either been set by the user through the site tree or automatically by OmCore.
  • ID
    Integer
    The database ID of the page. Useful for displaying content only on certain pages.
  • header_script
    String
    Contains any javascript which has been set in the site or page header script field. This should be output just before the closing <head> tag.
  • footer_script
    String
    Contains any javascript which has been set in the site or page footer script field. This should be output just before the closing <body> tag.
  • canonical_url
    String
    The canonical URL of the page (if one has been set).
  • minify()
    String
    This method can be used to serve a minifed and combined version of your CSS or JS files. Pass in the the CSS or JS files you want to serve either as an array or in a comma delimited fashion. The method returns the full <script> or <style> tag needed to embed the minifed version on the page. Do not mix CSS and JS files together when minifying, instead make 2 seperate calls to minify() e.g {{ header.minify({'default.js','jquery.js'}) }} or {{ header.minify('reset.css','layout.css','print.css') }}

Template object

template

This contains useful variables which makes building templates quicker

Properties

  • name
    String
    The filename of the current template. e.g. mytemplate or promo_template
  • path
    String
    The absolute path to the current template folder. Useful when including resources such as javascript, CSS and images.
    E.g. {{ template.path }}images/logo.png would output /assets/templates/mytemplate/images/logo.png

Content object

content

This object has no preset variables, instead they are based on the name of the content areas that content is assigned to within the site tree.

Each content area is listed under a lowercase version of its name (with underscores instead of spaces) . So “Banner area” becomes content.banner_area, “Teaser area” becomes content.teaser_area. E.g. {{ content.main_area }} will output all the content types assigned to the Main Area within the site tree.

Page object

page

The page object contains data about the current page being viewed.

Example:

{% if page.slug == ‘home-page’ %}
{{ <h1>You are on the homepage</h1> }}
{% endif %}

Properties

  • id
    Integer
    The current page ID.
  • page_name
    String
    The page name set in the site tree.
  • slug
    String
    The URL friendly slug of the current page. e.g. contact-us
  • navigation
    String
    The navigation group the page is assigned to.
  • class
    String
    The class name assigned to this page in the site tree (if set). This class name is also automatically populated in header.classes
  • parent
    Integer
    The page ID of the parent page (if this is a sub page)
  • preview_mode
    String
    If the page is being viewed in preview mode then this tag returns the HTML which is needed to display the checkboxes along the top of the page. It must be inserted directly after the <body> tag. We don’t recommend you remove this from your template since you will lose preview mode functionality.

Interface object

interface

The interface object consists of methods which can be used to generate pre-built HTML widgets such as navigation and breadcrumbs which can be used on a page. Each method can take a single parameter, a hash, containing options which affect the output.

Properties

  • breadcrumbs()
    Method
    Returns the page breadcrumbs in a <ul> list with additional classes and elements to help with styling. There are no optional parameters which can be passed.
  • navigation()
    Method
    Returns a nested <ul> list structure to be used as navigation. Its possible to target entire navigation groups or the children of a single page, displaying as many levels of children as you need. The HTML which is output contains additional classes to help style selected pages and parents.

    If no options are passed then the top level of the main navigation group of the site is output.
    {{ interface.navigation() }}

    Return the top level and 1 level of children from the Primary navigation group.
    {{ interface.navigation({'group':'Primary navigation', 'levels': 1}) }}
  • content()
    Method
    Returns either a single piece of content, a content area, or the area from a specific page.

    Return a single piece of content with ID 1234
    {{ interface.content({'id':'1234'}) }} or
    {{ interface.content(1234) }}

    Return the Footer area from a specific page with ID 678
    {{ interface.content({'page_id':'678', 'area':'Footer area'}) }}
  • logo()
    Method
    Returns a logo image wrapped in a link to the sites homepage. If no logo file is passed in as a parameter the method searches in /assets/templates/<template_name>/images/ for a file named either logo.png, logo.jpg or logo.gif

    Display a logo from /assets/templates/mytemplate/images/logo.png
    {{ interface.logo() }}

    Display a custom named logo file
    {{ interface.logo('/assets/templates/mytemplate/images/new_green_logo.gif') }}
  • powered_by()
    Method
    To be used in a site footer. Returns a short snippet of HTML with a “powered by OmCore” logo and a link back to www.omcore.net

0 comments

Post is closed for comments.