2

I am trying the following with no luck

<?php $category = "{exp:cat2:id category_url_title='{segment_4}'}"; ?>
{exp:playa:parents channel="article|blogs|calendar_events|contests|podcasts|videos" category="<?= $category ?>" field="show" limit="24"}

    // Do something here

{/exp:playa:parents}

This is wrapped by {exp:channel:entries} tag. Now If I provide the value of category hard coded it returns the results but not if I pass it in like the above. Even if I assign the value of $category = '2' it wont return any results. Any ideas ?

5
  • this may be a parse order related issue. If the code works when hard coded, then I suspect that the php variable is not being inserted at the time that its needed. Are you able to rework your tags/code to do away with the php? perhaps Low seg2cat would work better and allow you to use the segment/category variable directly in the playa tags?
    – pixldev
    Feb 14, 2017 at 0:30
  • @pixldev Yes that is exactly the problem. I have removed php code and used cat2 directly and also set parse="inward" on playa expression and it worked.
    – Deepak SK
    Feb 14, 2017 at 0:54
  • @DeepakSK. If it solved out your issue, can you provide your solution to answer and mark it accepted so others can get help? Feb 14, 2017 at 5:11
  • @MufaddalNala Have posted it.. will accept it when it allows me to.
    – Deepak SK
    Feb 14, 2017 at 22:46
  • Good job.. keep it up Feb 15, 2017 at 2:46

1 Answer 1

3

I have resolved this by adding the option parse="inward" to the {exp:playa:parents} tag. So my code looks like below

{exp:playa:parents  channel="article|blogs|calendar_events|contests|podcasts|videos" category="YOUR_DYNAMIC VALUE FROM PHP OR ANOTHER TAG" field="show" limit="24" parse="inward"}

    // Do something here

{/exp:playa:parents}

The above code worked as long as there is no pagination required inside the playa:parents block. For pagination to work you need to provide var_prefix="your_prefix" option but then it will have to modify the code to reference your variables based on the prefix set. I avoided that by using embed. So basically you can put the whole Playa code inside another file and embed them where you want to use it. So the playa code will look something like below

{exp:playa:parents  channel="article|blogs|calendar_events|contests|podcasts|videos" category="YOUR_DYNAMIC VALUE FROM PHP OR ANOTHER TAG" field="show" limit="24" entry_id="{embed:entry_id}"}

    // Do something here

{/exp:playa:parents}

Note I have removed the parse option and added entry_id option which should be same as the parent entry ID you are trying to find the parents for.

Hope that helps!

Your Answer

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

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