0

Articles on my site are structured as /[category_url_title]/article/[article_url_title].

Now, I want to have at the bottom of my articles a section that says "related articles", and then list a few more articles from the same category. I have the same template for all articles.

This works perfectly fine:

{exp:channel:entries category="100" limit="3" dynamic="off" url_title="not {segment_3}"}
{title}<br>
{/exp:channel:entries}

But I need the category parameter to be set dynamically from {segment_1} which is the category's url title. However, the channel:entries tag will only accept category id, not category url title as a parameter.

I have cat2 installed, but this doesn't work:

{exp:channel:entries category="{exp:cat2:id category_url_title='{segment_1}'}" limit="3" dynamic="off" url_title="not {segment_3}"}
{title}<br>
{/exp:channel:entries}

I've also tried saving the value of the cat2 tag output as a php variable, but that doesn't work either.

I assume my above efforts don't work because of mixed parse order of EE. So how can I make this work?

1 Answer 1

1

If you want to parse a plugin as a parameter, you need to set the parameter parse as inward.

{exp:channel:entries parse="inward" category="{exp:cat2:id category_url_title='{segment_1}'}" limit="3" dynamic="off" url_title="not {segment_3}"}
  {title}<br>
{/exp:channel:entries}

Since different categories on different groups can share the same name, is a good idea to specify the category_group parameter on the cat2 add-on.

One more thing. The values of the parameter dynamic should be yes or no.

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.