0

Question is related to using ExpressionEngine version 2.10.1

I'm trying to build a page which lists PDF catalogues belonging to a particular brand. Brands are unique, but each brand may have 1 or more catalogues.

Set up in EE is as follows:

  • Each brand name has been entered under Channel Administration > Categories.
  • There are channels called 'Brand' and 'Catalogue'.
  • When a channel entry is made under 'Brand' it is assigned to the appropriate brand category - using the Categories tab when making the channel entry. The same applies when making channel entries under 'Catalogue', i.e. they are also assigned to the appropriate brand category.

Template starts like this:

{exp:channel:entries channel="brands"}
...
{/exp:channel:entries}

Where I've put [...] I want to retrieve anything in the 'Catalogue' channel which has been assigned to the appropriate brand category ID. I can read the brand category ID like this but not sure what to do next:

{categories}{category_id} {/categories} 

After this I'm stuck because I can't use another {exp:channel:entries} tag inside an existing one, unless I'm wrong?

Any help appreciated. I had a look at solutions which use custom queries, e.g. by using {exp:query sql=" but that doesn't seem right?

To clarify why I am starting by looping through the "brands" channel: the markup for the page requires a lot of other information about the brand to be output by the template.

1 Answer 1

0

You literally can use a {exp:channel:entries} loop inside of another one using template embeds. Here is an example:

{exp:channel:entries channel="brands"}

    {categories}

        {embed="embeds/my_embed" cat_id="{category_id}"}

    {/categories}

{/exp:channel:entries}

and then, you have a template group (you'll have to make it) called embeds with a my_embed template with contents like this:

{exp:channel:entries category="{embed:cat_id}"}

    Product Name - {title}
    etc...

{/exp:channel:entries}

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.