Use perch related ID in filter?

  • Hi,


    [SOLVED] - See end of post


    Is it possible to use the ID of a perch:related tag in a filter?


    I'm using the code below to display a featured card in a sidebar. It's displayed everywhere, except on the page it's promoting. The idea being when a user is on that page the card isn't shown.


    It works, but there are four perch:related tags that the CMS admin could pick. So having the ID feat_listen_up hard coded isn't very flexible.



    I've created $related_id using the code below:


    Code
    1. $related_id = perch_collection('Opportunities', [
    2. 'filter' => 'opp_name_slug',
    3. 'match' => 'eq',
    4. 'value' => perch_get('s'),
    5. 'skip-template' => 'true',
    6. 'return-html' => 'true',
    7. ]);


    Update:

    The example below checks if an ID is set, if is, it sets $related_id_filter  which I then use in one of the filters.


  • Stephen Meehan

    Changed the title of the thread from “Expose perch related ID in template?” to “Use perch related ID in filter?”.