Retired Documentation:  You are using the documentation for version 1.7.3 which was retired in 2013. Go here for the latest version documentation or check here for your available upgrades to the latest version.

Photo Gallery Entries Variables

The standard {exp:gallery:entries} tag has a multitude of variables that can be used inside of it. These variables have been split into two broad categories:

Single Variables

caption

{caption}

The caption associated with the entry.

category

{category}

The name of the category that the entry is assigned to.

category_id

{category_id}

The category ID of the category that the entry is assigned to.

category_path

{category_path='gallery/category'}

The URL to the specified template. The category ID will be automatically added. For example, this:

<a href="{category_path='weblog/category'}">{category}</a>

Could be rendered like this:

<a href="http://example.com/index.php/gallery/category/C12/">Florida</a>

count

{count}

The "count" out of the current entries being displayed. If five entries are being displayed, then for the fourth entry the {count} variable would have a value of "4".

custom_field_one

Up to six custom fields can be shown, with the following syntax:

{custom_field_one} {custom_field_two} {custom_field_three} {custom_field_four} {custom_field_five} {custom_field_six}

entry_date

{entry_date format="%Y %m %d"}

The date the entry was submitted. See the date variable formatting page for more information.

entry_id

{entry_id}

The ID number of the gallery entry

filename

{filename}

The raw filename of the image associated with the entry. For instance, zoo.jpg.

height

{height}

The height (in pixels) of the full-size image.

id_path

{id_path='gallery/comments'}

The URL to the specified template. The ID number of the entry will be automatically added. For example, this:

<a href="{id_path='gallery/comments'}">my entry</a>

Would be rendered like this:

<a href="http://example.com/index.php/gallery/comments/234/">my entry</a>

image_url

{image_url}

The URL to the full-size image.

medium_height

{medium_height}

The height (in pixels) of any "medium sized image" associated with the entry.

medium_url

{medium_url}

The URL to any "medium sized image" associated with the entry.

medium_width

{medium_width}

The width (in pixels) of any "medium sized image" associated with the entry.

recent_comment_date

{recent_comment_date format="%Y %m %d"}

The date of the most recent comment associated with the entry. See the date variable formatting page for more information.

switch=

{switch="option_one|option_two|option_three"}

This variable permits you to rotate through any number of values as the entries are displayed. The first entry will use "option_one", the second will use "option_two", the third "option_three", the fourth "option_one", and so on.

The most straightforward use for this would be to alternate colors. It could be used like so:

{exp:gallery:entries}
{entries}

{row}
<td class="{switch="one|two"}">
<a href="{id_path='gallery/comments'}"><img src="{thumb_url}" width="{thumb_width}" height="{thumb_height}" alt="{title}" title="{title}" /></a><br />
{title}
</td>
{/row}

{/entries}
{/exp:gallery:entries}

The entries would then alternate between <div class="one"> and <div class="two">.

Multiple instances of the {switch=} tag may be used and the system will intelligently keep track of each one.

thumb_height

{thumb_height}

The height (in pixels) of any thumbnail associated with the entry.

thumb_url

{thumb_url}

The URL to any thumbnail associated with the entry.

thumb_width

{thumb_width}

The width (in pixels) of any thumbnail associated with the entry.

title

{title}

The title of the entry.

total_comments

{total_comments}

The total number of comments for this entry.

total_results

{total_results}

The total number of entries being displayed.

views

{views}

The total number of views for this entry.

width

{width}

The width (in pixels) of the full-size image.

Conditional Variables

Conditional variables allow you to add scripting to your regular variables in order to show data if certain criteria that you define are met. For more information about conditional logic in ExpressionEngine, please refer to the Global Conditionals.

Note: The left side of the condition must always be the name of a variable (title, body, summary, username, screen_name, entry_date, etc.). The right side must be the condition you are testing for.

For example, to test for the "caption" being not empty, you would do this:

{if caption != ""}

The caption is not empty!

{/if}

An alternate, shorthand syntax can accomplish the same thing:

{if caption}

The caption is not empty!

{/if}

If only the variable name is in the conditional statement it tests for "not empty".

allow_comments

{if allow_comments}
content
{/if}

This special conditional lets you conditionally display content if the current entry is set to allow comments.

{if allow_comments}

({comment_total}) <a href="{id_path='gallery/comments'}">Comments</a>

{/if}

{if no_results}

{if no_results}
content
{/if}

You may use this conditional for displaying a message in the case when no entries are returned. The contents inside of the conditional will be displayed in cases where there are no results returned for the tag.

{if no_results}

<p>There are no entries available.</p>

{/if}

Top of Page