Jump to main content Jump to doc navigation

One thing Gallery lacks out-of-box is assigning albums to a resources. To get this, you'll need to create a Listbox tv and use EVAL-binding to create the Listbox items dynamically.

To assign a gallery to a specific resource, do the following.

1. Install Gallery extension

2. Create some galleries, and fill them with images.

3. Create a chunk named "galleryDropdownList" for instance.

[[+name]]==[[+id]]||

4. Create a new tv with a name "assignedGallery". Input options:

Input type = Listbox (single- or multi- - depends on how many galleries you want to assign to a resource).

Input Option Values (just copy-paste the following code):

$output = $modx->runSnippet("GalleryAlbums",array("rowTpl"=>"galleryDropdownList"))."none==0"; return $output;

OR as an alternative to point 3 and 4, use this Select as Input Option Values (benefit: no need of @EVAL and no need of a chunk):

@SELECT GROUP_CONCAT(name, '==', id SEPARATOR '||') FROM `modx_gallery_albums` WHERE active=1

Default Value: 0

Enable Type-Ahead: Yes

Force Selection to List: Yes

5. Assign your tv to a templates of a desired resources, and select some category for it. Save.

6. Open target resource in manager, go to Template Variables, and locate your tv. Choose proper gallery album for it, and click Save, when you done.

7. In your page template, place the following code where you expect your gallery to be rendered:

[[!Gallery? &album=`[[*assignedGallery]]`]]

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
  • Chris Fickling
  • CrewMark
  • deJaya
  • eydolan
  • Following Sea
  • Lefthandmedia
  • Murray Wood
  • Anton Tarasov
  • Stéphane Jäggi
  • Raffy
  • Snow Creative
  • Nick Clark
  • A. Moreno
  • JT Skaggs
  • Helen
  • YJ
  • krisznet
  • Richard
  • Yanni

Budget

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

Learn more