• ♡ Sponsor

    Runtime Variables

    #Context #Loop #Variable

    There are some variables defined by Automad during runtime. The names of those runtime variables are always preceded with a colon as follows:

    @{ :basename }
    

    Runtime variables can be subdivided into two types - context related variables and variables created within control structures.

    Context Related

    :basename
    The basename of a page directory or file.
    :current
    Returns true in case a page is the currently requested page (URL).
    :currentPath
    Returns true in case the page's URL is part of the URL of the current page.
    :level
    The level of a page in the virtual site tree.
    :mtime
    The modification date and time of a page.
    :origUrl
    The original URL of a page, in case an override is defined for the url variable.
    :parent
    The URL of the parent of the current page.
    :path
    The file system path of a page.
    :template
    The template used to render a page.

    Created by Control Structures

    :caption
    A caption associated with the current file in a foreach loop or with statement.
    :file
    The file path of the current file when iterating over a list of files.
    :filelistCount
    The number of files in the currently defined list of files.
    :fileResized
    The file path of the resized version of the current file when iterating over a list of files.
    :filter
    The current filter tag in a loop when iterating over a list of filters of a pagelist.
    :height
    The height of the current file in a loop or with statement.
    :heightResized
    The height of the resized version of the current file in a loop or with statement.
    :i
    The index of the current iteration within loops.
    :now
    The current date and time.
    :pagelistCount
    The number of pages in the current pagelist — ignoring the pagelist limit and pagination.
    :pagelistDisplayCount
    The number of pages actually displayed.
    :paginationCount
    The number of pages of the pagination of the currently defined pagelist, in case a maximum number of pages is defined for the list.
    :tag
    The current tag in loop when iterating over the list of page tags.
    :width
    The width of the current file in a loop or with statement.
    :widthResized
    The width of the resized version of the current file in a loop or with statement.

    Related

    Template Language  ⁄
    Variables — Template Language

    The actual value of a variable is depending on the current context. In most cases the context is the currently requested page. However, control structures can change the context to any other page during runtime, for example when iterating over a list of pages. In case a variable ...

    Variables  ⁄
    Reserved Variables — Variables

    Some variables have reserved names and are always defined. They can be found on top of the page/shared data section in the dashboard. Reseverd variables can be used like normal page variables.

    Template Language  ⁄
    Pipe — Template Language

    A pipe | allows for using the value of a variable to be the input value for a function. It is also possible to chain multiple functions together, so that the output of one function is used as input for the next one. Therefore a pipe can be used to modify the value of a variable ...

    Toolbox  ⁄
    queryStringMerge — Toolbox

    Creates a query string containing the specified paramters as key/value pairs merged with the existing query string of the current URL. This method can be used to create links for adding or replacing some parameters of the query string without touching the other ones. A standard ...

    Toolbox  ⁄
    set — Toolbox

    Sets shared, session or runtime variables by passing key/value pairs as option array.

    Template Language  ⁄
    Control Structures — Template Language

    As in other languages, control structures in Automad are statements that dynamically determine the flow of an application or website based on evaluating content or variables. Automad knows four different statements to control the flow of the application: for, foreach, if and ...

    Control Structures  ⁄
    for — Control Structures

    The for loop iterates over a range of numeric values of type integer.

    Control Structures  ⁄
    foreach — Control Structures

    The foreach loop iterates over objects. Depending of the type of the object in use, Automad provides different runtime variables within the code block of the loop to refer to items of the object. The :i variable refers to the index of the current iteration in the loop.

    Control Structures  ⁄
    with — Control Structures

    The with statement allows for processing code associated with a given page or file. When using a page's URL or one of the keywords prev and next as an argument, the context within the block of code changes to that page. When using a file path, it is possible to access related ...

    • Automad
    • Developer Guide
    • Building Themes
    • Template Language
    • Variables
    • Runtime Variables
    Discuss
    Packages
    Release Notes
    Support
    Terms of Use
      Become a Sponsor
      GitHub
      Twitter
      Facebook
      Instagram
      2013-2022 by Marc Anton Dahmen
    Released under the MIT license

    A faceless machine, creating one's portrait in the internet.
  • Automad
  • Getting Started
  • System
  • User Guide
  • Developer Guide
  • Headless Mode
  • Discuss
  • Packages
  • Developer Guide ←
  • Building Themes ←
  • Template Language ←
  • Variables
  • Reserved Variables
  • Runtime Variables