Support Center

About Koken

This Help Center provides support for Koken, a free content management system designed for photographers, artists and designers.

Lens variables

Lens variables

Last Updated: Nov 17, 2015 02:25PM EST

Variables display simple string data, like an album title. Some variables are global and may be used anywhere while others are used with specific data sources. Variables are wrapped with double curly braces and may used independently or inside traditional HTML tags.

Here's an example of a variable used independently to print the site title.

<html>
  <body>
    <koken:load>
      <h1>
       {{ site.title }}
     </h1>
    </koken:load>
  </body>
</html>

In this example we use the global {{ site.keywords }} variable inside a meta tag:

<meta name="keywords" content="{{ site.keywords }}" />

Global variables

These variables may be inserted into any template to display their value.

Variable Description
{{ count }} Number of items in a data source. Insert before <koken:loop> in any loaded data source.
{{ labels.album.plural }} Plural version of the album label.
{{ labels.album.singular }} Singular version of the album label.
{{ labels.archive.plural }} Plural version of the archive label.
{{ labels.archive.singular }} Singular version of the archive label.
{{ labels.category.plural }} Plural version of the category label.
{{ labels.category.singular }} Singular version of the category label.
{{ labels.content.plural }} Plural version of the content label.
{{ labels.content.singular }} Singular version of the content label.
{{ labels.essay.plural }} Plural version of the essay label.
{{ labels.essay.singular }} Singular version of the essay label.
{{ labels.favorite.plural }} Plural version of the favorite label.
{{ labels.favorite.singular }} Singular version of the favorite label.
{{ labels.page.plural }} Plural version of the page label.
{{ labels.page.singular }} Singular version of the page label.
{{ labels.set.plural }} Plural version of the set label.
{{ labels.set.singular }} Singular version of the set label.
{{ labels.tag.plural }} Plural version of the tag label.
{{ labels.tag.singular }} Singular version of the tag label.
{{ labels.timeline.plural }} Plural version of the timeline label.
{{ labels.timeline.singular }} Singular version of the timeline label.
{{ location.here }} Current URL, relative to the site path. e.g., "/" for front page, '/albums/name' for an album page.
{{ location.host }} Protocol plus host domain. e.g., "http://koken.me"
{{ location.hostname }} Just the host domain. e.g., "koken.me"
{{ location.parameters.page }} Page number of the current page. Used with pagination.
{{ location.root_folder }} Relative path to the subfolder the site is publishing to, if applicable.
{{ location.site_url }} Full URL to the published site. Same as "URL" in Settings > Site Publishing.
{{ location.template }} Name of the template being viewed. e.g., if added to contents.lens then "contents" would be published.
{{ location.theme_path }} Relative path to the theme's folder.
{{ now }} Output the current time as a unix timestamp.
{{ profile.name }} The publisher's display name.
{{ profile.first }} The publisher's first name.
{{ profile.last }} The publisher's last name.
{{ profile.email }} The publisher's email address.
{{ profile.google_plus }} The publisher's Google+ profile url.
{{ profile.twitter }} The publisher's twitter username.
{{ profile.facebook }} The publisher's facebook page URL.
{{ rss.contents }} URL to the public content RSS feed.
{{ rss.essays }} URL to the published essays RSS feed.
{{ rss.timeline }} URL to the Timeline's RSS feed.
{{ site.title }} The site's title.
{{ site.copyright }} The site's copyright.
{{ site.description }} The site's description. Used for meta tag / SEO purposes.
{{ site.keywords }} The site's keywords. Use for meta tag / SEO purposes.
{{ site.tagline }} The site's tagline.
{{ year }} Output the current year.

Language variable

This global variable may be inserted into any template to display language specific content when paired with a theme's language setting.

<koken:link title="{{ language.read_title collate='essay.title' }}">{{ language.read_more }}</koken:link>

The default language variables can be found in the language region of /koken/app/site/defaults.json. Additional translations can be added to custom themes with a language region in the theme's info.json. 

"language": {
  "en": { "read_more": "Read more" },
  "fr": { "read_more": "En savoir plus" },
  "de": { "read_more": "Mehr lesen" }
}

Published sites will display the language selected from the language theme setting.

"Language": {
  "icon": "info",
  "settings": {
    "language": {
      "label": "Language",
      "type": "select",
      "options": [
        { "label": "English", "value": "en" },
        { "label": "French", "value": "fr" },
        { "label": "German", "value": "de" }
      ],
      "value": "en"
    }
  }
}

By using a %s placeholder and the collate variable transformer you can merge a language variable with another variable's value.

info.json

"read_title": "read %s"

template.lens

<h3>{{ language.read_title collate="essay.title" }}</h3>

Data variables

Data variables are used to render data loaded from a particular source (images, albums, essays, etc). See templates for an overview of which templates load each of the following data sources.

album

A single album or set.

Variable Description
{{ album.album_type }} The album type. Values include "standard" and "set".
{{ album.context.total }} Total albums in the parent collection this album belongs to.
{{ album.context.position }} Numerical index of album in relation to its parent collection.
{{ album.counts.total }} Total number of items the album contains.
{{ album.counts.videos }} Total number of videos the album contains.
{{ album.counts.images }} Total number of images the album contains.
{{ album.covers.first.presets.tiny.url }} Absolute URL to an album's primary cover using the tiny preset size.
{{ album.covers.first.presets.url }} Absolute URL to an album's primary cover using the small preset size.
{{ album.covers.first.presets.medium.url }} Absolute URL to an album's primary cover using the medium preset size.
{{ album.covers.first.presets.medium_large.url }} Absolute URL to an album's primary cover using the medium large preset size.
{{ album.covers.first.presets.large.url }} Absolute URL to an album's primary cover using the large preset size.
{{ album.covers.first.presets.extra_large.url }} Absolute URL to an album's primary cover using the extra large preset size.
{{ album.covers.first.presets.huge.url }} Absolute URL to an album's primary cover using the huge preset size.
{{ album.created_on }} Date the album was created. Formatted example.
{{ album.created_on.datetime }} Date the album was created in YYYY/MM/DD HH:MM:SS format.
{{ album.created_on.timestamp }} Date the album was created in UNIX timestamp format.
{{ album.description }} The album's description.
{{ album.id }} The album's internal ID.
{{ album.modified_on }} Date the album was last modified. Formatted example
{{ album.modified_on.datetime }} Date the album was last modified in YYYY/MM/DD HH:MM:SS format.
{{ album.modified_on.timestamp }} Date the album was last modified in UNIX timestamp format.
{{ album.published_on }} Date the album was published. Formatted example
{{ album.published_on.datetime }} Date the album was published in YYYY/MM/DD HH:MM:SS format.
{{ album.published_on.timestamp }} Date the album was published in UNIX timestamp format.
{{ album.public }} Boolean for the album's visibility. Returns true if public, false if unlisted.
{{ album.rss }} URL to the current album's RSS feed.
{{ album.summary }} The album's summary.
{{ album.tags field="" separator="" }} Outputs a list of all assigned tags. field (optional) is to use a tag property other than its title. separator (optional) inserts a character in-between each tag.
{{ album.title }} The album's title.
{{ album.url }} Absolute site url for the album.

archives

List of all categories, tags and dates plus previews of all assigned content.

Variable Description
{{ archive.title }} Title of the archive's criteria. E.g., "Portrait" when viewing items in the Portrait category.
{{ archive.type }} Type of archive data loaded. E.g., "tag", "category".
{{ archive.type.plural }} Type of archive data loaded in plural form. E.g., "Tags".
{{ archive.type.singular }} Type of archive data loaded in singular form. E.g, "Tag".

content

A single public or unlisted image/video.

Variable Description
{{ content.aspect_ratio }} Returns the aspect ratio (width/height) of the original uploaded item (not always available for videos, depending on the server configuration).
{{ content.caption }} The content's caption.
{{ content.captured_on }} Date the image was captured. Formatted example
{{ content.captured_on.datetime }} Date the image was captured in YYYY/MM/DD HH:MM:SS format.
{{ content.captured_on.timestamp }} Captured on date in UNIX timestamp format.
{{ content.context.total }} Total items in the content's parent collection.
{{ content.context.position }} Numerical index of content in its parent collection.
{{ content.duration }} Length of a video (e.g, "4:20")
{{ content.id }} Content's internal ID.
{{ content.is_cover }} Boolean for whether an image is assigned as a collection's cover. Returns value in context of collections only.
{{ content.is_cover_primary }} Boolean for whether an image is assigned as a collection's primary (first) cover. Returns value in context of collections only.
{{ content.favorite }} Boolean for whether the content is marked as a favorite.
{{ content.featured }} Boolean for whether the content is marked as featured.
{{ content.filename }} Content's original filename.
{{ content.filename.clean }} Content's original filename stripped of its file suffix and hyphens/underscores replaced with spaces.
{{ content.filesize }} Content's original file size (in bytes).
{{ content.file_type }} Returns the content's type ("image", "video").
{{ content.geolocation.latitude }} Returns latitude data from an image's geolocation.
{{ content.geolocation.longitude }} Returns longitude data from an image's geolocation.
{{ content.height }} Returns the height of the original uploaded item (not always available for videos, depending on the server configuration).
{{ content.license.clean }} Ready to print string representation of the license (All rights reserved, Creative Commons, etc).
{{ content.license.raw }} Shorthand notation for content's license (all, y,n, y,s, etc).
{{ content.modified_on }} Date the content was last modified. Formatted example
{{ content.modified_on.datetime }} Modified on date in YYYY/MM/DD HH:MM:SS format.
{{ content.modified_on.timestamp }} Modified on date in UNIX timestamp format.
{{ content.published_on }} Date the content was published. Formatted example
{{ content.published_on.datetime }} Date the content was published in YYYY/MM/DD HH:MM:SS format.
{{ content.published_on.timestamp }} Date the content was published in UNIX timestamp format.
{{ content.presets.extra_large.url }} Absolute URL to the extra large preset image.
{{ content.presets.huge.url }} Absolute URL to the huge preset image.
{{ content.presets.large.url }} Absolute URL to the large preset image.
{{ content.presets.medium.url }} Absolute URL to the medium preset image.
{{ content.presets.medium_large.url }} Absolute URL to the medium large preset image.
{{ content.presets.small.url }} Absolute URL to the small preset image.
{{ content.presets.tiny.url }} Absolute URL to the tiny preset image.
{{ content.public }} Boolean for the content's visibility. Returns true if public, false if unlisted.
{{ content.source.title }} Displays the third party service name if content was imported. E.g., "Instagram", "Vimeo", etc. Nothing is returned if content was uploaded directly.
{{ content.source.url }} Displays the third party service url if content was imported. E.g., "http://instagram.com/p/1234". Nothing is returned if content was uploaded directly.
{{ content.tags field="" separator="" }} Outputs a list of all assigned tags. field (optional) is to use a tag property other than its title. separator (optional) inserts a character in-between each tag.
{{ content.title }} The content's title.
{{ content.uploaded_on }} Date the content was uploaded. Formatted example
{{ content.uploaded_on.datetime }} Uploaded on date in YYYY/MM/DD HH:MM:SS format.
{{ content.uploaded_on.timestamp }} Uploaded on date in UNIX timestamp format.
{{ content.url }} Absolute site url for the content.
{{ content.width }} Returns the width of the original uploaded item (not always available for videos, depending on the server configuration).

essay

A single essay.

Variable Description
{{ essay.content }} Body of the essay.
{{ essay.created_on }} Date the essay was created. Formatted example
{{ essay.created_on.datetime }} Created on date in YYYY/MM/DD HH:MM:SS format.
{{ essay.created_on.timestamp }} Created on date in UNIX timestamp format.
{{ essay.excerpt }} Returns first 255 characters after all HTML removed.
{{ essay.featured }} Boolean for whether the essay is marked as featured.
{{ essay.id }} The internal ID of the essay.
{{ essay.modified_on }} Date the essay was last modified. Formatted example
{{ essay.modified_on.datetime }} Modified on date in YYYY/MM/DD HH:MM:SS format.
{{ essay.modified_on.timestamp }} Modified on date in UNIX timestamp format.
{{ essay.published_on }} Date the essay was published. Formatted example
{{ essay.published_on.datetime }} Date the essay was published in YYYY/MM/DD HH:MM:SS format.
{{ essay.published_on.timestamp }} Date the essay was published in UNIX timestamp format.
{{ essay.tags field="" separator="" }} Outputs a list of all assigned tags. field (optional) is to use a tag property other than its title. separator (optional) inserts a character in-between each tag.
{{ essay.title }} Title of the essay.
{{ essay.url }} Absolute site url for the essay.

event

Variable Description
{{ event.title }} Used in calendar archive templates to display the type of archive being viewed (date, tag, category).

page

A single custom page.

Variable Description
{{ page.content }} Body of the page.
{{ page.created_on }} Date the page was created. Formatted example
{{ page.created_on.datetime }} Created on date in YYYY/MM/DD HH:MM:SS format.
{{ page.created_on.timestamp }} Created on date in UNIX timestamp format.
{{ page.id }} The internal ID of the page.
{{ page.modified_on }} Date the page was last modified. Formatted example
{{ page.modified_on.datetime }} Modified on date in YYYY/MM/DD HH:MM:SS format.
{{ page.modified_on.timestamp }} Modified on date in UNIX timestamp format.
{{ page.published_on }} Date the page was published. Formatted example
{{ page.published_on.datetime }} Date the page was published in YYYY/MM/DD HH:MM:SS format.
{{ page.published_on.timestamp }} Date the page was published in UNIX timestamp format.
{{ page.title }} Title of the page.
{{ page.url }} Absolute site url for the page.

Tag variables

Some template tags include their own variables. Those variables are formatted the same, but are only used with their parent tags so they're documented separately in template tags.

Variable transformations

Variable output can be customized by adding the following attributes.

Attribute Type Description Default
autolink Boolean Converts any occurrence of "http://" found in a string to a hyperlink. Is automatically set to true when paragraphs (see below) is set to true. false
case String Modifies the string’s character case. Options include "upper", "lower", "title" and "sentence". empty
collate String Merges one or more comma separated variables into a language variable. E.g.,  {{ language.read_title collate='essay.title' }} empty
date_only Boolean Used when printing dates. When set to “true” the date is printed without the time stamp. false
date_format String Used when printing dates. Applies custom formatting to the date that’s printed. Options replicate the PHP date function. empty
html_encode Boolean Encodes any ampersands, double quotes, and/or carets found in the string to their HTML entity equivalent. For example, & would be published as &. false
if_true String Used with boolean variables. If the variable returns true, the value of if_true is printed. E.g., <article class="{{ essay.featured if_true="featured"}}"></article> empty
paragraphs Boolean Formats text as paragraphs when set to “true”. Line breaks create new paragraphs. false
strip_html Boolean Strips HTML elements from the string. Useful when publishing text in a place where HTML can't be included. When true the html_encode property is enabled. false
time_only Boolean Used when printing dates. When set to “true” the time stamp is printed without the date. false
truncate Number Limits the returned string to a number of characters. empty
url_encode Boolean Encodes the string for url compatibility. false

Examples

In this example we truncate an album's description to a maximum of 100 characters.

{{ album.description truncate="100" }}

Here's an example that formats a date using the date_format attribute to display only the year. See this PHP date function document for other characters.

{{ content.modified_on date_format="Y" }}

Output a variable to JSON

For situations where you want to use Lens data in JavaScript, the to_json helper can be used to output arrays and objects to a JSON string.

<koken:load source="contents" limit="10" order_by="uploaded_on">
  <script>
    var latest = {{ content.to_json }};
  </script>
</koken:load>

If you only need certain fields, you can specify those fields to speed things up and also keep your JavaScript objects smaller.

<koken:load source="contents" limit="10" order_by="uploaded_on">
  <script>
    var latest = {{ content.to_json fields="title,caption,presets" }};
  </script>
</koken:load>

Fallback variables

If the value of a variable is empty you may designate a fallback variable to use instead. To do so you include both variables separated by a | character. The example below demonstrates how {{ content.title }} may fallback to {{ content.filename }} if {{ content.title }} is empty.

{{ content.title | content.filename }}

Adding, subtracting, multiplying and dividing variables

If you need to output a numerical value from two or more variables, you can do that by separating each variable with * (multiply), / (divide), + (add) or - (subtract). Example:

<koken:covers minimum="{{ settings.cols * settings.rows }}">
  <koken:loop>
    <koken:img />
  <koken:loop>
<koken:load>
support@koken.me
http://assets2.desk.com/
false
koken
Loading
seconds ago
a minute ago
minutes ago
an hour ago
hours ago
a day ago
days ago
about
false
Invalid characters found
/customer/en/portal/articles/autocomplete