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 Comments

The Gallery Comments Tag enables you to show the user-submitted comments associated with your gallery entries.

Note:  This Tag is intended for use in one of your "single entry" pages.  That is, a page that contains the gallery entry ID number in the URL.

Here is a basic example showing how you might use the comment tag:

{exp:gallery:comments sort="asc" limit="20"}

{comment}

<p>By {name} on {comment_date format="%Y %m %d"}</p>

{/exp:gallery:comments}

Parameters

dynamic=

dynamic="off"

The gallery and comment display engines set some parameters dynamically, based on what is in the URL. There are times, however, where you do not want the parameters affected by what the URL contains. To override the dynamic nature of the comment tag, use dynamic="off".

This is often useful if you want to list comments in a "sidebar" on your site and have them always be the same ones regardless of which page on your site you visit (main page, archives, comments, etc.). Using this, you can create a "recent comments" list. By setting dynamic="off" you will ensure that the list is not affected by anything passed in the URL.

gallery=

gallery="vacations"

From which gallery to show the comments (will show comments from any gallery if no gallery is specified).

The gallery= parameter can have some security implications. If you do not use this parameter then it is possible that people could see comments for a gallery entry that they otherwise would not have access to. If you use multiple galleries and want to make sure only certain people can see certain content, then you're encouraged to make use of this parameter.

limit=

limit="30"

Allows you to limit the number of comments. The limit will default to 100 comments if a value is not specified. If you are using pagination then this will determine the number of comments shown per page.

orderby=

orderby="date"

The "order" parameter sets the display order of the comments. Setting options for this parameter include:

If you are combining the display of comments and trackbacks, then you may only set this parameter to date.

paginate=

paginate="top" paginate="bottom" paginate="both"

This parameter is for use with entry pagination and determines where the pagination code will appear for your gallery entries:

  1. top: The navigation text and links will appear above your list of entries.
  2. bottom: The navigation text and links will appear below your list of entries.
  3. both: The navigation text and links will appear both above and below your list of entries.

If no parameter is specified, the navigation block will default to the "bottom" behavior.

sort=

sort="asc" sort="desc"

The sort order can be "asc" (ascending order or "oldest item first") or "desc" (descending order or "newest item first"). If you do not use a sort order the default is desc.

Variables

author_id

{author_id}

The ID corresponding to the comment author's member profile. This is only applicable if the comment was left by a registered member. Non-registered commenters will return a zero (0).

This can be useful for creating links to the commenter's member profile:

<a href="http://example.com/index.php/member/{author_id}/">{name}</a>

aol_im

{aol_im}

The author's AOL IM account name

comment

{comment}

The body of the comment

comment_id

{comment_id}

The ID associated with the comment

entry_id

{entry_id}

The ID number of the entry

entry_id_path

{entry_id_path='gallery/comments'}

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

<a href="{entry_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>

icq

{icq}

The author's ICQ IM user identification number

interests

{interests}

The author's "interests" as entered in their profile

ip_address

{ip_address}

The IP address of the commenter

location

{location}

The author's location as entered in their profile

member_search_path

{member_search_path='search/results'}

This variable is replaced by a URL that passes the author's member name to your search results Template. In this way, you can display all entries made by the author. You should specify the Template_Group/Template that you use to display search results. For example:

<a href="{member_search_path='search/results'}">View entries by this member</a>

msn_im

{msn_im}

The author's MSN IM account name

occupation

{occupation}

The author's occupation as entered in their profile

name

{name}

Name of the author

permalink

{permalink}

The URL to the actual comment with anchor. Put this variable in a link:

<a href="{permalink}">permanent link</a>

switch=

{switch="option_one|option_two"}

This variable permits you to alternate between any two values as the entries are displayed. The first entry will use "option_one", the second will use "option_two", the third "option_one", and so on.

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

{exp:gallery:comments}
<div class="{switch="one|two"}">
<h1>{name}</h1>
{comment}
</div>
{/exp:gallery:comments}

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.

title

{title}

The title of the gallery entry with which the comment is associated.

url

{url}

The author's raw URL, if it exists

url_or_email

{url_or_email}

URL if it exists, otherwise the email address

url_or_email_as_author

{url_or_email_as_author}

Hyperlink or email link as author screen_name (or username if they haven't specified a screen name)

url_or_email_as_link

{url_or_email_as_link}

Same as above only it will display the URL or email address as a link

yahoo_im

{yahoo_im}

The author's Yahoo IM account name

Custom Member Fields

All custom member profile fields can be accessed using the "short name" of the field:

{age}
{gender}
{zodiac}
etc..

These are totally dynamic in that any profile field you create for your members will automatically be available by its "short name" as a variable.

Single Variable Dates

Several date variables are available for use. As with other date variables, these require the "format" parameter in order to define how the date should be displayed. See the date variable formatting page for more information.

comment_date

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

The date of the comment.

edit_date

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

The date on which the comment was edited.

Conditionals

Conditionals work in comments:

if no_results

{if no_results}
content
{/if}

You may use this conditional for displaying a message in the case when no comments 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 comments for this entry yet.</p>

{/if}

Comment Submission Form

{exp:gallery:comment_form}

{/exp:gallery:comment_form}

There is one parameter in the comment form but only if you want to use the preview feature:

{exp:gallery:comment_form preview="gallery/preview"}

The "preview" parameter specifies the template group/template in which the preview will be shown. More on previewing later.

The comment form is created pretty much like a normal form, only you don't specify the opening and closing form tags. There are a few variables that are required in order to enable people's personal information (name, email, url, etc.) to appear in the form. Here's how the comment form is typically created:

{exp:gallery:comment_form preview="gallery/preview"}

{if logged_out}

<p>Name: <input type="text" name="name" value="{name}" size="50" /></p>

<p>Email: <input type="text" name="email" value="{email}" size="50" /></p>

<p>Location: <input type="text" name="location" value="{location}" size="50" /></p>

<p>URL: <input type="text" name="url" value="{url}" size="50" /></p>

{/if}

<p><textarea name="comment" cols="70" rows="10">{comment}</textarea></p>

<p><input type="checkbox" name="save_info" value="yes" {save_info} /> Remember my personal information</p>

<p><input type="checkbox" name="notify_me" value="yes" {notify_me} /> Notify me of follow-up comments?</p>

{if captcha}

<p>Please enter the word you see in the image below:</p>

<p>{captcha}<br />
<input type="text" name="captcha" value="{captcha_word}" maxlength="20" /></p>

{/if}

<input type="submit" name="submit" value="Submit" />
<input type="submit" name="preview" value="Preview" />

{/exp:gallery:comment_form}

Notes:
The conditional variable {if logged_out} allows the system to show the short form (textarea only) if the user is a logged in member. We recommend you use the form this way because if a member is logged in, their personal data is fetched automatically.

Notice the variables in the "value" form fields? These allow us to show the user's information in the form automatically if they click the "remember personal info" option.

Previewing

To preview a comment requires that you create a specific template for it. This template will contain at minimum two tags. The first is the tag that shows the preview:

{exp:gallery:comment_preview}

{comment}

{/exp:gallery:comment_preview}

The second is the comment form tag from earlier. This allows the comment to be displayed as well as the form containing the info so it can be previewed again or submitted.

Variables

comment

{comment}

The body of the comment.

comment_date

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

The date of the comment. As with other date variables, this requires the "format" parameter in order to define how the date should be displayed. See the date variable formatting page for more information.

email

{email}

The email address of the comment author.

location

{location}

The author's location as entered in their profile or the comment entry form.

name

{name}

Name of the author.

url

{url}

The author's raw URL, if it exists.

url_or_email

{url_or_email}

URL if it exists, otherwise the email address.

url_or_email_as_author

{url_or_email_as_author}

Hyperlink or email link as author screen_name (or username if they haven't specified a screen name).

url_or_email_as_link

{url_or_email_as_link}

Same as above only it will display the URL or email address as a link.

Conditionals

The following conditionals are available:

Top of Page