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
  • Jens Wittmann – Gestaltung & Entwicklung
  • Fabian Christen
  • Digital Penguin
  • Dannevang Digital
  • Sepia River Studios
  • CrewMark
  • Chris Fickling
  • deJaya
  • Following Sea
  • Anton Tarasov
  • eydolan
  • Raffy
  • Lefthandmedia
  • Murray Wood
  • Snow Creative
  • Nick Clark
  • Helen
  • JT Skaggs
  • krisznet
  • YJ
  • Yanni
  • Richard

Budget

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

Learn more