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.

Category URL Titles In Links not work with {exp:channel:categories}

October 12, 2011 3:54pm

Subscribe [3]
  • #1 / Oct 12, 2011 3:54pm

    ahmad saad

    364 posts

    in this section i have two problems

    1- the url is http://electromed.biz/site/index.php/category/exhibitions

    the code:

    {exp:channel:categories channel="project"}{category_name}{/exp:channel:categories}

    the indicator “category” not work and the code return all cat

    when i use:

    {exp:channel:entries channel="project"}{categories}{category_name}{/categories}{/exp:channel:entries}

    the indicator “category” work properly and the code return only cat in the url

    how i can make exp:channel:categories work

    2- in this code:

    {exp:channel:entries channel="project"}{categories}{category_name}{/categories}{/exp:channel:entries}

    if the url like this http://electromed.biz/site/index.php/category/exhibitions1

    notice exhibitions1 not exist.

    the code return all entries

    how can i make it not return entries if cat not exist.

     

  • #2 / Oct 12, 2011 4:20pm

    ahmad saad

    364 posts

    any one help me please

  • #3 / Oct 12, 2011 4:56pm

    ahmad saad

    364 posts

    :coolsmile:

  • #4 / Oct 12, 2011 5:11pm

    ahmad saad

    364 posts

    😊

  • #5 / Oct 12, 2011 8:34pm

    You can expect a reply from EllisLab within 24 hours. Responses aren’t always immediate, as they’re busy supporting tons of us users out there. Just be patient and they’ll get back to you.

    I think I can help you with number 1, though.

    The category URL trigger only works on the Channel Entries tag, not the Channel Categories tag.

    The Channel Categories tag is actually meant for listing out categories assigned to a given channel, not for accessing information about the category in the URL.

    You could use the Category Heading tag pair to access the currently viewed category.

    {exp:channel:category_heading}{/exp:channel:category_heading}

    That would work just like you’re trying to use the Channel Categories tag now.

    I personally tend to use a third party add-on for this purpose. Low Seg2Cat is a free extension that, once installed, allows you to access category information easily, based on the URL segments.

    Hope that helps.

     

  • #6 / Oct 12, 2011 8:42pm

    And just quickly searching around, I found the answer for the second part of your request.

    The Channel Entries tag has a category_request conditional variable, which you can use to determine if a category is filtering the results of the Channel Entries tag.

    You can view information about the variable in the user guide.

    Basically, your code will look something like this:

    {exp:channel:entries channel="project"}
         {if category_request} 
              {categories}{category_name}{/categories}
         {/if}
    {/exp:channel:entries}
  • #7 / Oct 12, 2011 8:52pm

    ahmad saad

    364 posts

    thanks for reply it worked very well

  • #8 / Oct 12, 2011 9:37pm

    Kyle Cotter

    730 posts

    Glad to see Jeremy’s replies were helpful to you Ahmad.

    If you run into any more issues, feel free to start a new thread.

    Thanks.

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

ExpressionEngine News!

#eecms, #events, #releases