Jump to main content Jump to doc navigation

GalleryItem Snippet

The GalleryItem snippet displays a single Gallery Item.

Properties

Name Description Default Value
id The ID of the item to display
toPlaceholders If true, will set the properties of the Item to placeholders. If false, will use the tpl property to output a chunk. 1
toPlaceholdersPrefix Optional. The prefix to add to placeholders set by this snippet. Only works if toPlaceholders is true. galitem
tpl Name of a chunk to use when toPlaceholders is set to false. galItem
albumTpl Name of a chunk to use for each album that is listed for the Item. galItemAlbum
albumSeparator A string separator for each album listed for the Item. ,
albumRequestVar The REQUEST var to use when linking albums. galAlbum
tagTpl Name of a chunk to use for each tag that is listed for the Item. galItemTag
tagSeparator A string separator for each tag listed for the Item. ,&nsbp;
tagSortDir A the direction to sort the tags listed for the Item. DESC
tagRequestVar The REQUEST var to use when linking tags. galTag
thumbWidth The max width of the generated thumbnail, in pixels. 100
thumbHeight The max height of the generated thumbnail, in pixels. 100
thumbZoomCrop Whether or not to use zoom cropping for the thumbnail. 1
thumbQuality The quality of the thumbnail, from 0-100. 90
thumbFar The "far" value for phpThumb for the thumbnail, for aspect ratio zooming. C
thumbProperties A JSON object of parameters to pass to phpThumb as properties for the thumbnail.
imageWidth The max width of the generated image. 500
imageHeight The max height of the generated image. 500
imageZoomCrop Whether or not to use zoom cropping for the image. 0
imageQuality The quality of the image, from 0-100. 90
imageFar The "far" value for phpThumb for the generated image, for aspect ratio zooming. C
imageProperties A JSON object of parameters to pass to phpThumb as properties for the generated image.

Default Placeholders

When toPlaceholders is set to 1, GalleryItem automatically sets placeholders for the item. They are prefixed by default with 'galitem', but you can change that with the toPlaceholdersPrefix parameter. A list of these placeholders is as follows:

Name Description
name The name of the Item.
filename The filename of the item. This will be relative to the path where the files are stored, which is usually assets/components/gallery/files/.
description The description of the item.
mediatype The media type of the Item. Currently this is only 'image'.
createdon The timestamp that this Item was created on.
createdby The User ID of the creator of this Item.
active If this Item is active or not. Can be 1 or 0.
albums A list of Albums this Item is in.
tags A list of Tags associated with this Item.
url If set, a URL for this Item.

GalleryItem Chunks

There are 3 chunks that are processed in GalleryItem. Their corresponding GalleryItem parameters are:

  • tpl - The Chunk to use if toPlaceholders is set to 0.
  • albumTpl - The Chunk to use for each Album listed with the item.
  • tagTpl - The Chunk to use for each Tag listed with the item.

Examples

Display the Item with ID 12, but only if it exists.

[[!GalleryItem? &id=`12`]]
[[!+galitem.image:notempty=`
    <div class="image">
    <a href="[[+galitem.image]]">
    <img src="[[+galitem.image]]" alt="[[+galitem.name]]" />
    </a>
    <br />Albums: [[+galitem.albums]]
    <br />Tags: [[+galitem.tags]]
    </div>
`]]

Display the Item with ID 23, but use a Chunk called 'Photo' for display.

[[!GalleryItem?
    &id=`23`
    &toPlaceholders=`0`
    &tpl=`Photo`
]]

Display the Item with ID 432 with a Chunk called 'Photo', but separate the Tags associated with it by a pipe ("|"):

[[!GalleryItem?
    &id=`432`
    &toPlaceholders=`0`
    &tpl=`Photo`
    &tagSeparator=` | `
]]

See Also

  1. Gallery.Gallery
    1. Gallery.Gallery.containerTpl
    2. Gallery.Gallery.thumbTpl
  2. Gallery.GalleryAlbums
    1. Gallery.GalleryAlbums.containerTpl
    2. Gallery.GalleryAlbums.rowTpl
  3. Gallery.GalleryItem
    1. Gallery.GalleryItem.albumTpl
    2. Gallery.GalleryItem.GalleryItemPagination
    3. Gallery.GalleryItem.tagTpl
    4. Gallery.GalleryItem.tpl
  4. Gallery.Plugins
    1. Gallery.Plugins.Galleriffic
    2. Gallery.Plugins.Slimbox
  5. Gallery.Setting Up Your Gallery
  6. Gallery.Example1
  7. Gallery.Setting Up the GalleryItem TV

Support the team building MODX with a monthly donation.

The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.

Backers

  • modmore
  • STERC
  • Digital Penguin
  • Jens Wittmann – Gestaltung & Entwicklung
  • Fabian Christen
  • Dannevang Digital
  • Sepia River Studios
  • CrewMark
  • Chris Fickling
  • deJaya
  • eydolan
  • Lefthandmedia
  • Murray Wood
  • Following Sea
  • Anton Tarasov
  • Stéphane Jäggi
  • Raffy
  • Snow Creative
  • A. Moreno
  • Nick Clark
  • JT Skaggs
  • Helen
  • YJ
  • krisznet
  • Richard
  • Yanni

Budget

$306 per month—let's make that $500!

Learn more