HiFi Variable

The hifi variable is globally available to Twig templates. It is used to access the HiFi API, some handy methods as well as site/system properties.


hifi.get(object) - Perform a custom query on the HiFi data store.

{% for post in hifi.get({'type':'post'}) %}

hifi.merge(object[,object][,array][,string]) - Merges multiple hifi queries or result sets optionally ordered by a passed in string. Any number of object queries and arrays of results can be passed in. If multiple strings are passed in, only the last one will be used for ordering. If no ordering string is passed in, and a result appears in multiple parameters, the order from the first will be used.

{% for post in hifi.merge({'type':'post'},{'type':'gallery'},'-publishedAt')) %}

jsonify(value) - Convert a value, including objects and arrays, to JSON.

{% set var as hifi.jsonify(array) %}


  • urls- An array of  URL related values ( hifi.url.NAME )
    • hifi.url.host - The host part of the URL of the page you are on (i.e. docs.gethifi.com)
    • hifi.url.path - The path part of the URL of the page you are on (i.e. /developers/templates/twig/the-hifi-variable)
    • hifi.url.files - The URL to reach the files.* subdomain where user-uploaded content. Ends in a slash.
    • hifi.url.ui - The URL to reach the ui.* subdomain where developer content lives. Ends in a slash.
    • hifi.url.images - The URL to reach the images folder on the ui subdomain. Ends in a slash
    • hifi.url.scripts - The URL to reach the scripts folder on the ui subdomain. Ends in a slash
    • hifi.url.styles - The URL to reach the styles folder on the ui subdomain. Ends in a slash
  • http- An array of HTTP related values ( hifi.http.NAME )
    • hifi.http.get - An array of GET variables from the query string
    • hifi.http.post - An array of POST variables
    • hifi.http.vars - An array of all GET, POST, and COOKIE variables
    • hifi.http.method - The HTTP method used to call the page (usually GET)
    • hifi.http.referrer - The URL which referred the traffic to a page, if it exists
    • hifi.http.referer - Alias of referrer, common misspelling dating back to HTTP spec
    • hifi.http.agent - The client's user-agent string
  • settings- An array of site settings
    • hifi.settings.googleAnalyticsId - The Web Property ID from Google Analytics
    • hifi.settings.timezone - The geographical timezone the site is in
    • hifi.settings.title - The site's name
    • hifi.settings.email - The administrators' e-mail address
    • hifi.settings.global.header - Markup to appear in every page's document head tag
    • hifi.settings.global.body_prefix - Markup to appear at the top of every page
    • hifi.settings.global.body_suffix - Markup to appear at the bottom of every page
  • user- The current user. If nobody is logged in, it is the Anonymous user whose "firstName" attribute will be "Anonymous".
    • hifi.user.firstName
    • hifi.user.lastName
    • hifi.user.email
    • hifi.user.id
    • hifi.user.created
  • now - The current unix timestamp (hifi.now)