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.

Listing categories within a post

May 26, 2008 8:36pm

Subscribe [2]
  • #1 / May 26, 2008 8:36pm

    tb1200

    18 posts

    Hey there EE experts,

    I know this probably isn’t the best common practice but… Is it possible to generate a category menu dynamically from within a blog post?  For example, in the body field, I’ve pasted the same code that I’m using for one of my category menus…

    {exp:weblog:categories weblog="ourcollection" category_group="2" show="21|22|23|24|25|33"}
      <a href="http://{path=our-collection/index}">{category_name}</a>
    {/exp:weblog:categories}

    However, once published, the post shows only the above code, rather than generating and rendering the category list.

  • #2 / May 26, 2008 8:51pm

    Sue Crocker

    26054 posts

    Close!

    You need to do the following:

    {categories}
    <a href="http://{path=our-collection}">{category_name}</a> 
    {/categories}
  • #3 / May 26, 2008 9:18pm

    tb1200

    18 posts

    Hi, thanks for your quick reply, Sue!

    For some reason, the post is still simply showing the code, rather than the category list?  Here is what I’m inserting into my body field - perhaps I’m misunderstanding…

    _____________


    Some of the regions these authentic discoveries originate from include:
    {categories}{category_name}{/categories}

    _____________

    Also, the categories I would like to display are actually from a different weblog than the one I’m posting too…  Perhaps this is where the confusion lays?

    -Tim

  • #4 / May 26, 2008 9:22pm

    Sue Crocker

    26054 posts

    I’m sorry, I missed that you were wanting to do that within a post.

    Where in the post would you want to put the info? In other words, could you simply put it between two different fields?

  • #5 / May 26, 2008 9:30pm

    tb1200

    18 posts

    I originally hard coded the category list into the template but now I’m using the template to for multiple pages and this category list will only appear within one of the pages that uses this template. 

    I could definitely create a different / new weblog field if that would help provide a solution?

    Will it cause any issues being that I want to display categories from a different weblog than the one I’m posting to?

  • #6 / May 26, 2008 9:50pm

    Sue Crocker

    26054 posts

    You could do something like:

    {if weblog_id == 2}
    {categories}
    <a href="http://{path=our-collection}">{category_name}</a>
    {/categories} 
    {/if}

    But that involves the categories coming from a particular weblog.

  • #7 / May 27, 2008 11:44am

    tb1200

    18 posts

    Hmmm, not sure if I can go that route either because there are 4 pages within the same weblog using this template and only one of those pages needs the category list.  I suppose we may need to just break down and manually type category list into the blog post… not the biggest worry in the world.  Thanks for your suggestions Sue, I appreciate it.

  • #8 / May 27, 2008 1:20pm

    Robin Sowell

    13255 posts

    Yep- I don’t love putting it in the body myself.  Might do a custom field ‘show cat list’ yes/no dropdown- use that as a conditional and put the tag itself on the template.  But if you need to put EE code inside an entry and have it parsed- you have to use a plugin- i.e. allow EE code plugin.

    But I’ll admit- I’m a bit fuzzy on what all you’re doing.

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

ExpressionEngine News!

#eecms, #events, #releases