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.

passing a category_id to a path

November 17, 2007 1:43pm

Subscribe [1]
  • #1 / Nov 17, 2007 1:43pm

    adam11238

    34 posts

    I’m trying to build a link, displayed on a single entry page, which will go back to all entries in the same category. My first thought was to somehow attach the current category_id onto the end of the path in the link, but I can’t figure out how to get the category_id of the currently viewed entry. Is there a built in way to do this that I’m missing?

    Many thanks.

  • #2 / Nov 18, 2007 11:00am

    Robin Sowell

    13255 posts

    Try the categories variable pair- it will list all of the cats an entry is in- and allow you to format them as links (with the proper cat indicator on the end of the urls).  So- something like:

    {exp:weblog:entries parameters…..}
    {title}
    {categories}} <a href="http://{path=weblog/index}">{category_name}</a> {/categories}
    {/exp:weblog:entries}

    See if that does the trick.

  • #3 / Nov 18, 2007 11:22am

    adam11238

    34 posts

    Thanks, Robin. That’s actually what I settled on, but it’s not exactly what I was trying to do. I have the categories listed in the sidebar, but I wanted a link at the bottom of a single entry that said “Back to all posts in [this category].” So, that link would need to know which category the single entry was in, and I couldn’t figure out how to get that info.

    I’d also really like a way to combine the archive and category tags, so that if someone is viewing entries in a particular category, the archive links will only show archived entries for that category, not all archived entries for the weblog. It makes navigation a little confusing if someone clicks on a category, then clicks on an archive link and is taken to all entries in the weblog.

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

ExpressionEngine News!

#eecms, #events, #releases