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;

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]]`]]