Dot All Lisbon – the official Craft CMS conference – is happening September 23 - 25.

Global Variables

Every single template is going to get loaded with the following variables:

now

A datetime object set to the current date and time.

Today is {{ now|date('M j, Y') }}.

siteName

The name of your site, as defined in Settings → General.

siteUrl

The URL of your site. (See How Craft Determines the Site URL)

currentUser

A UserModel object set to the currently logged-in user (if there is one).

{% if currentUser %}
    Welcome, {{ currentUser.friendlyName }}!
{% endif %}

loginUrl

The URL to your site’s login page, based on the config2:loginPath config setting.

{% if not currentUser %}
  <a href="{{ loginUrl }}">Login</a>
{% endif %}

logoutUrl

The URL Craft uses to log users out, based on the config2:logoutPath config setting. Note that Craft will automatically redirect users to your homepage after going here; there’s no such thing as a “logout page”.

{% if currentUser %}
  <a href="{{ logoutUrl }}">Logout</a>
{% endif %}

Global Set Variables

Each of your site’s global sets get GlobalSetModel object to represent them.