MODX Community

Gallery - The name of selected album

Hello!

It seems that thumbTpl does not have a placeholder for album name and I didn’t find an example for containerTpl. How can I get the name of current album, to place under thumbs?

Thank you!

1 Like

On this page we have a placeholder called

[[+gallery.name]]`

In the “Displaying the selected album” section of this page, here’s the whole sample code

[[!Gallery? &album=`1` &toPlaceholder=`gallery`]]
<h1><a href="[[~[[*id]] &galAlbum=`[[+gallery.id]]`]]">[[+gallery.name]]</a></h1>
<p>[[+gallery.description]]</p>
 
[[+gallery]]

HTH

https://docs.modx.com/extras/revo/gallery/gallery.setting-up-your-gallery

But then here we also have album_name as a placeholder, guess this one may be what you want

https://docs.modx.com/extras/revo/gallery/gallery.gallery/gallery.gallery.containertpl

Thanks!

Your solution seems better than using containerTpl. I’l try.
Somehow, it would be nice to have the album name in thumbTpl, too. So, I stripped all the code from the Gallery snippet, I made one more snippet, and I let only this:

$gallery = $modx->getService(‘gallery’,‘Gallery’,$modx->getOption(‘gallery.core_path’,null,$modx->getOption(‘core_path’).‘components/gallery/’).‘model/gallery/’,$scriptProperties);
if (!($gallery instanceof Gallery)) return ‘’;
$modx->lexicon->load(‘gallery:web’);

$data = $modx->call(‘galItem’,‘getList’,array(&$modx,$scriptProperties));

if ($data[‘album’][‘description’] != ‘’){
return $data[‘album’][‘description’];
}else{
return $data[‘album’][‘name’];
}

So, I can call the snippet from thumbsTpl.
It is dirty, I know :slight_smile:

1 Like

Great! Glad I could help!

I don’t think its too dirty :laughing: as long as you haven’t hacked the core then all will be well, within reason of course.

That’s the key to Modx, you should never hack the core processors, but you can modify extras pretty freely for maximum control. Its possible to run into trouble, but in this case if it works, I’d call it a job well done!

PS One note is to save your work, as any editing of default Gallery/thumbTpl files will be overwritten in the event of an update of the extra. Luckily that doesn’t happen all that often, usually.

No, I didn’t modify the extra. I made a new snippet, using from gallery snippet only the part which retrieve the album name from the database. The plugin remained untouched.

1 Like

Ok then you have nothing to worry about