Getting Gallery Cover from Template Variable in MODX

There is a case where the gallery's cover needs to be listed alongside the pagetitle of resources, where the gallery is connected by a Template Variable.

Example:

If you don't know how to add this type of Template Variable, just create a TV, and select "galleryalbumlist" as its Input Type.

Now, the problem is that there no snippet to pull out the value of the TV into the list.

 

Example of listing the resources:

Snippet call:

<nav class="menu">
[[!pdoMenu?
&parents=`-0,[[*parent]]`
&level=`1`
&tpl=`pdoMenuHoverImage`
]]
</nav>

pdoMenuHoverImage chunk:

<li[[+classes]]>
<a href="[[+link]]" [[+attributes]]>[[+menutitle]]</a>[[+wrapper]] [[!getGalleryCoverByTV?
&resourceId=`[[+id]]`
&tv=`gallery`
&toPlaceholder=`getGalleryCoverByTV`
]]
[[+getGalleryCoverByTV:notempty=`
<img src="[[+getGalleryCoverByTV]]" class="dass-project-nav-image is-hidden">
`]]
</li>

So, this is the custom snippet for it.

getGalleryCoverByTV

Output example:

 



Comments

blog comments powered by Disqus