1

I have tried to use Cat2 addon to retrieve category ID based on a category group. Later I want to use stashed category ID to retrieve entries form a channel based on a selected category. Code looks like:

{exp:stash:set name="catid" parse_tags="yes" parse_depth="3"}
{exp:cat2:id category_url_title="{segment_2}" category_group="5" parse="inward"}
{category_id}
{/exp:cat2:id}
{/exp:stash:set}

CatID#: {exp:stash:get name='catid'}

    {exp:channel:entries channel="collection" category="{exp:stash:get name='catid'}" url_title="{segment_3}" status="open"}
        {title}
        {collection_description}
    {/exp:channel:entries}

It displays proper CatID# but I'm not getting any entries. When I "hardcode" that CatID# instead of {exp:stash:get name='catid'} I'm able to retrieve related entries.

Any clue what is going on there?

Thanks

1 Answer 1

1

Found solution here

If you need to use a Stash variable that was created within a Channel Entries loop earlier in a template as a parameter in a Channel Entries loop, you can delay the parse order of the second Channel Entries loop such that the variable gets set prior to the loop being executed. For example if you got a list of entry IDs of related entries (from Relationships or Playa) you could put those in the entry_id parameter and then print out the entries in the correct order. This could be used for categories, statuses, search values, whatever.

Example code:

{exp:stash:parse process="end"}
  {exp:channel:entries channel="XXX" fixed_order="{stash:places}" entry_id="{stash:places}" dynamic="no"}
    {title}
  {/exp:channel:entries}
{/exp:stash:parse}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.