We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 38917
    • 17 Posts
    I've been searching for a nice solution to highlight the current album - so that it behaves like Wayfinder which adds 'active' class to the current <li> item. Thanks to some posts on modx forum I've found out how to do it. It works - so I'm sharing it - in case someone needs it in the future.

    I'm using Galleriffic plugin. I was basing on this forum post: -> http://forums.modx.com/thread/73577/galleryalbums-hereclass

    1) I created a new template for a gallery page with a snippet call inside
    [[!Gallery? &album=`2` &plugin=`Galleriffic` &numThumbs=`3` &enableTopPager=`0`  ]]
    


    2) added
    [[!GalleryAlbums]]

    to galleriffic.chunk (core/components/gallery/elements/chunks/galleriffic.chunk.tpl)

    3) modified galAlbumRowTpl
    <li[[+cls:notempty=``]] class=" [[!If? &subject=`[[!GetUri]]` &operator=`==` &operand=`/galeria/[[+id]]/` &then=`active`]] " >
        <a href="galeria/[[+id]]/">[[+showName:notempty=`[[+name]]`]]</a>
    </li>
    


    4) created GetUri snippet - BobRay thank you! -> http://forums.modx.com/thread/71166/on-getting-the-current-window-ressource-id

    5) added one line to .htaccess:

    # The Friendly URLs part
    RewriteRule ^galeria/([^/]+)/$ galeria.html?galAlbum=$1 [L,QSA]
    


    -> http://forums.modx.com/thread/?thread=71379&page=1

    In case someone didn't want friendly urls with gallery, then galAlbumRowTpl would have to be something like this

    <li[[+cls:notempty=``]] class=" [[!If? &subject=`[[!GetUri]]` &operator=`==` &operand=`/[[~[[*id]]? &[[+albumRequestVar]]=`[[+id]]`]]` &then=`active`]] " >
        <a href="[[~[[*id]]? &[[+albumRequestVar]]=`[[+id]]`]]">[[+showName:notempty=`[[+name]]`]]</a>
    </li>


    ...and no changes in the .htaccess.

    [ed. note: janevi last edited this post 11 years, 5 months ago.]
      muriz.com
      • 34049
      • 28 Posts
      Thanks for the heads up on this, whilst I'm developing my site I still have friendly urls switched off. I don't know whether it's my setup but the galAlbumRowTpl quoted above didn't quite work as expected. I had to make a couple of small changes to the position of the ]] in the operand. The following tpl works for me.

      <span class="[[!If? &subject=`[[!GetUri]]` &operator=`==` &operand=`/[[~[[*id]]?]]&[[+albumRequestVar]]=[[+id]]` &then=`gal-album-active`]]">
      <a href="[[~[[*id]]? &[[+albumRequestVar]]=`[[+id]]`]]"> [[+showName:notempty=`[[+name]]`]] </a></span>    

        • 44433
        • 33 Posts

        <li[[+cls:notempty=``]] class="[[!if? &subject=`[[*id]]` &operand=`==` &operator=`[[+id]]` &then=`active`]]" >
        <a href="[[~[[*id]]? &[[+albumRequestVar]]=`[[+id]]`]]">[[+showName:notempty=`[[+name]]`]]</a>
        </li>

        Had issues with this and found previous posts on Hereclass were using operator and operand the wrong way round so just want to post my workaround if it can help anyone.

        <li class="albumlist [[!If? &subject=`[[!GetUri]]` &operator=`EQ` &operand=`/[[~[[*id]]? &[[+albumRequestVar]]=[[+id]]]]` &then=`active`]]">


        gets the page as it appears in the address, gets the albums id + albumRequestVar + album id and compares it to make the active page's class = "albumlist active" [ed. note: christoflee last edited this post 10 years, 9 months ago.]
          Follow me on twitter @christofvonlee