Gallery2:Themes:Reference:Variables - Gallery Codex
Personal tools


From Gallery Codex

You can view all variables available on a particular page by turning on debug mode.

Some variables are made available in all themes / template files. Among these are:

  • isEmbedded -- True if site is viewed embedded in another application; false if viewed standalone.

User Information

Information about the active user:

  • $user.userName, $user.fullName, $, ... all user attributes
  • $user.isGuest, $user.isRegisteredUser, $user.isAdmin which help to create page content that is only visible to logged in users (registeredUser) or admins, or guests.

Example code for G2 .tpl files:

 {if $user.isRegisteredUser}
 Welcome {$user.userName}!
 Welcome, guest!

Item Information

  • $ is the id (unique identifier) of the item shown in the current page. in photo.tpl, $ is the id of the current data item (e.g. a photo)
  • Generally, you have access to all members of GalleryItem, e.g. $theme.item.canContainChildren is true for albums, false for photos and other data items.
  • $theme.item.title, $theme.item.summary, $theme.item.description are available as well. Don't forget to use the |markup modifier when using them.
  • Look at the smarty debug console to a list of all available variables.


Add comments link for the :

 {g->url arg1="view=comment.AddComment" arg2="itemId=`$`"}

Show comments link:

 {g->url arg1="view=comment.ShowComments" arg2="itemId=`$`"}

Page specific info

 {if $theme.pageType != 'admin'}
 this is seen on all pages except for the admin page.
 {if isset($controller) && ($controller == 'core.UserLogin')}
 login page only
  {if empty($theme.parents)}
  {if $theme.pageType != 'admin'}
  stuff on root album only and not a admin page