0

I am using the {categories} tag pair to link entries to their relevant section, however, when I use the following code it does not display child categories.

{exp:channel:entries channel="section" category="{section_category_num}"}
<h1>{title}</h1>
{intro_text}
</div>
</article>

</section>

<section>
<article class="container">
{sub_section}
<div class="product eight columns alpha">
<div class="product_img">
<img src="{sub_section:product_photo}" title="" />
<div class="triangle"></div>
</div>
<div class="product_info">
<h4>{sub_section:categories limit="1"}<a href="/living-room/{category_url_title}">{sub_section:title}</a>{/sub_section:categories}</h4>
{sub_section:product_description}
</div>
</div>
{/sub_section}
</article>
</section>
{/exp:channel:entries}

Since this is a section page, what I want to be able to do is to reference the related entries child category url to link to the relevant sub section.

Any guidance will be appreciated.

Thanks.

P.S. I did attempt to use GWCode Categories but without success.

  • Is {sub_section} a native Relationship field, and you're trying to access the categories loop which belongs to the child entry? – Derek Hogue Feb 12 '14 at 22:51
  • Yes. That is correct. – forrest Feb 12 '14 at 23:09
0

It seems like you're most of the way there - you just need to make sure you prefix everything within your child entry loop.

{sub_section:categories limit="1"}
    {sub_section:category_id}        
    {sub_section:category_url_title}
    {sub_section:category_name}
{/sub_section:categories}
| improve this answer | |
  • Hi Derek, thanks for the response. For some reason, this code simply outputs code in between the tag pair, and does not return actual values. – forrest Feb 13 '14 at 14:37
  • Hmm, maybe I'm wrong about the prefixing? What happens if you remove the inner prefixes (but keep the outer prefix)? – Derek Hogue Feb 13 '14 at 14:57
  • If I do it like this: {sub_section:categories }<a href="/living-room/{category_url_title}">{sub_section:title}</a> {/sub_section:categories} I get both the parent and the child category URL title. Is there a way to only display the child URL? – forrest Feb 13 '14 at 15:07
  • One more thought here. Without limit="" it loops through all the categories and shows the link with the parent url and then with the child url. I tried to eliminate the parent category with show="not 2", but for some reason that gets ignored. Ideas? – forrest Feb 13 '14 at 15:12
  • Ha! that worked. I reloaded the page again and this time the show="not 2" worked. So I am good. Thanks. – forrest Feb 13 '14 at 15:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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