ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

List categories in a single line, divided by commas if more than one

September 21, 2009 3:04pm

Subscribe [2]
  • #1 / Sep 21, 2009 3:04pm

    tonyd3

    13 posts

    So at the bottom of the blog entries I want to list the associated categories like this:

    Categories:  Cat 1, Cat 2, Cat 3


    Easy enough - except I don’t want a comma if there is only one associated category, rather just list the category and NOT a comma:

    Categories:  Cat 1

    Not sure how to pull that off, here is the relavent code snippit so far, which obviously produces a comma at the end of any category name listed (when I only want it between multiples and not after the last one):

    Categories: {categories}<a href="http://{path=blog/view}">{category_name}</a>, {/categories}
  • #2 / Sep 21, 2009 6:45pm

    ChiefAlchemist

    913 posts

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases