0

I have this code. All seems fine but the categories info won't output between my H4 tags. Not sure what I am missing here but I think it has something to do with the 'related categories mode' parameter. Any help would be appreciated.

{exp:channel:entries channel="work" limit="20" status="New|Open" related_categories_mode="yes" custom_fields="yes"}
        {if no_results}
            <p class="alert">There are no related projects.</p>
        {/if}
        <li>
            <a href="{title_permalink="work/view"}" title="{title}"><img src="{project_th}" alt="{title}" />{if status == "New"}<img src="/_/img/new-work.png" class="new" alt="NEW Project - {title}" />{/if}</a>
            <h3><a href="{title_permalink="work/view"}" title="">{title}</a></h3>
            <h4>{categories backspace="2"}<a href="{path="work"}" title="">{category_name}</a> / {/categories}</h4>
            <p>{project_excerpt}</p>
        </li>
        {/exp:channel:entries}
1

According to the User Guide 1:

"Relationships, Reverse Relationships, Pagination, and Categories are not available when Related Category Mode is enabled."

| improve this answer | |
0

It's quite yucky and requires a lot of parsing, but you may be able to do this by nesting an embedded template with a second channel entries loop inside the first:

{exp:channel:entries 
    channel='work' 
    limit='20' 
    status='New|Open' 
    related_categories_mode='yes' 
    disable='pagination|member_data|custom_fields'
}
    {if no_results}
        <p class="alert">There are no related projects.</p>
    {/if}

    {embed='work/related_entries' entry_id='{entry_id}'}
{/exp:channel:entries}

And the embedded template (work/related_entries):

{exp:channel:entries 
    channel='work' 
    entry_id='{embed:entry_id}'
    status='New|Open' 
    disable='pagination|member_data'
}
    <li>
        <a href="{title_permalink='work/view'}" title="{title}">
            <img src="{project_th}" alt="{title}" />
            {if status == "New"}
                <img src="/_/img/new-work.png" class="new" alt="NEW Project - {title}" />
            {/if}
        </a>
        <h3><a href="{title_permalink='work/view'}" title="">{title}</a></h3>
        <h4>{categories backspace='2'}<a href="{path='work'}" title="">{category_name}</a> / {/categories}</h4>
        <p>{project_excerpt}</p>
    </li>
{/exp:channel:entries}

The key here is the entry_id variable which is passed from the first channel entries loop to the second.

I haven't tested this, but I think it should work.

| improve this answer | |
  • Many thanks I will give it a whirl and come back to you. – MarkerMaker May 6 '13 at 19:37

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.