Change theme:   

Variables

In every page template or component there's a number of variables that are always available.

Global objects

page

Page object that contains information about currently viewed page.

<!doctype html>
<html>
  <head>
    <title>{{ page.title }}</title>
  </head>
  <body>
    ...
  </body>
</html>

Refer to page object documentation for all attributes available on page.

site

Site object provides access to global, site-related values, i.e. menu structure or languages on site.

<!doctype html>
<html>
  <head>
    <title>{{ page.title }}</title>
    <meta name="keywords" content="{{ site.keywords }}">
  </head>
  <body>
    {% for language in site.languages%}
      <a href="{{ language.url }}">{{ language.title }}</a>
    {% endfor %}
  </body>
</html>

Refer to site object documentation for all site related attributes.

Asset directory paths

To generate absolute URI-s to asset directories (such as directories for images or stylesheets), there are number of convenience variables to generate paths to these directories. Edicy has the following conventions to store external files on site:

  • /assets Assets such as fonts to be used in page layouts and uploaded with design code editor
  • /images Images to be used in page layouts and uploaded with design code editor
  • /javscripts Javascript files that are uploaded with design code editor
  • /stylesheets Stylesheet files that are uploaded with design code editor
  • /photos Photos uploaded by user from "Files" section
  • /files All other uploaded by user from "Files" section

images_path

Example of creating path to image:

<img src="{{ images_path }}/background.png" border="0" />

Notice that you have to add trailing slash after variable.

javascripts_path

Example that links to javascript file:

<script src="{{ javascripts_path }}/jquery-min.js"></script>

stylesheets_path

<link rel="stylesheet" href="{{ stylesheets_path }}/style.css">

See also stylesheet_link convenience tag to include stylesheets on page template.

Session related variables

If your layout code needs to make some decisions based whether user has been logged into CMS or not, you can use these variables which return true when logged in. These variables can be used together with if or unless tags.

editmode

Editmode has some common usage scenarios:

  • Not generating HTML code for statistics engines, such as Google Analytics, in CMS editors to generate false statistics.
  • Not generating code for UI-candy bloat in public site, for example, Flash movies.
  • Generating in-page widgets to make editing page easier.

Example of not generating code for Google Analytics in editing mode:

{% unless editmode %}{{ site.analytics }}{% endunless %}

previewmode

Works nearly the same way as editmode but returns true only when in preview mode. Returns false when user is logged out.

{% if previewmode %}You are in preview mode!{% endif %}

Custom variables

You can create your own variables to be used in templates by using the assign tag.