collectionKey question

  • Hi,

    I'm using a list and detail setup to display posts from two collections , it works well but I'd like to be able to use the collectionKey within the template.

    If I can expose it I intend to use it in the ahref, like this:


    Using define('PERCH_DEBUG', true); I can see this in the Debug message

    SELECT collectionID, collectionTemplate FROM perch3_collections WHERE (collectionKey='Posts' OR collectionKey='Case Studies')

    If I can expose the collectionKey somehow, I'm hoping it'll be possible to manipulate it with PHP to make it slug friendly and use PerchSystem::set_var to make it visible to my perch template. :/

  • hus_hmd has created a very neat perch add-on which solves this problem.

    Here's the code I'm using to output items from multiple collections

    Within my post--listing.html template I added <perch:content id="collectionKey" urlify>, this takes the collectionKey and converts it into a slug friendly value.

    The post--listing.html template can now display a unique ahref based on its collection name (collectionKey).

    Download the Pipit add-on here: