0

This is the site with 2 category names in the blog:

http://www.hogarthlighting.co.uk/blog/article/melba-the-savoy-hotel-london

News Picture Lights.

I would like it to show this when there are 2 or more category names

News / Picture Lights

Would I use 'if' statements? I have tried but had no success.

2

You can use some variables from the Channel Categories loop to execute this.

Ref:

http://ee2docs.com/add-ons/channel/categories.html#variables

Inside of your Channel Categories loop:

{category_name} {if count != total_results}/{/if}

This places a / after each category name until you reach your last sequence of the loop.

Edit Oops, of course you have it in a {exp:channel:entries} loop. Here is your answer:

http://ee2docs.com/add-ons/channel/channel_entries.html#id149

Use the backspace param to cut off the end of your last loop. Example:

{categories backspace="2"}

    <a href="{path='blog'}">{category_name}</a> /

{/categories}

This will remove the last character of the last loop, the /. You might need to adjust the backspace number depending on your formatting.

| improve this answer | |
  • Thanks, I've got it in an entry tag. - so I don't think that will work. {exp:channel:entries channel="blog" limit="1" disable="member_data|pagination"} Category: {categories}<a href="{path="blog"}">{category_name} {if count != total_results}/{/if}</a>{/categories} </div> </div> {/exp:channel:entries} – user6821 Nov 6 '15 at 14:32
  • @user6821 I edited my answer to give you a better answer. – jrothafer Nov 6 '15 at 14:43

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.