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.

problem with conditional statement using category ID#s

September 24, 2009 12:01pm

Subscribe [3]
  • #1 / Sep 24, 2009 12:01pm

    roryrabbitfield

    320 posts

    Hi, I’ve posted about my sub-nav menu problem before, but I had to change the way it was coded and now I cannot get what I want anymore.

    I am trying to use a conditional statement to write some code to my template when I am in category 10 only, and not any of these categories: “C11|C12|C13|C14|C15”.

    I could use this:

    {if segment_3 == "C10"}
    code here….
    {/if}

    ...but this doesn’t work because the URL of the pages in category 10 do not have segment_3 in their URL; their segment_3 is the name of the blog entry within that category.
    Here is a url from page that is in category 10:
    http://64.106.177.24/index.php/seidenschein/practice_areas/421-a_benefits/

    So, to get around this I did the following:
    This is what is currently on the template “seidenschein/practice_areas”:

    {if segment_3 != "C11|C12|C13|C14|C15"}
    {exp:weblog:entries weblog="practice_areas" category="10" disable="pagination|member_data|trackbacks" dynamic="off" fixed_order="5|33|34|35|36" status="open"}
    <div class="spaceunder"><a href="http://{url_title_path=seidenschein/practice_areas}">{title}</a></div>
    {/exp:weblog:entries}
    {/if}

    However, when you are on a page where segment_3 DOES equal “C11|C12|C13|C14|C15”, the code inside the (if) statements DOES get written to the page. But it should not be doing so.
    A sample URL:
    http://64.106.177.24/index.php/seidenschein/practice_areas/C13/
    As you can see, the code (in the left column under the blue “practice areas” graphic) does get written, producing the 4 links you see there.

    How can I get this code to NOT be written to the page when segment_3 is one of these categories: “C11|C12|C13|C14|C15”

    For clarification:
    “practice_areas” is a weblog. It has these categories:
    C10|C11|C12|C13|C14|C15

    C10 is the “real estate tax incentives programs” link in the dropdown menu under “practice areas” in the top nav, and it has 4 entries in it (the ones that are being written by the code inside the conditional). The other links
    The other categories in the “practice areass” blog are accessed by the rest of the links in that dropdown menu.

    Thanks!
    Rory

  • #2 / Sep 24, 2009 12:07pm

    Sue Crocker

    26054 posts

    I’m confused. How or when does C11, whatever get added to the URL

  • #3 / Sep 24, 2009 12:09pm

    roryrabbitfield

    320 posts

    If you click on the 2nd link in the dropdown under “practice area” (top nav), you go to this page:

    http://64.106.177.24/index.php/seidenschein/practice_areas/C11/

    That is the URL that comes up, because this entry is in C11.

    Is that what you are asking?

  • #4 / Sep 24, 2009 12:24pm

    silenz

    1651 posts

    {if segment_3 != "C11" AND segment_3 !="C12" AND segment_3 !="C13" AND segment_3 !="C14" AND segment_3 !="C15"}
  • #5 / Sep 24, 2009 12:25pm

    Sue Crocker

    26054 posts

    Thanks for the assist, silenz.

    Rory, does that help?

  • #6 / Sep 24, 2009 12:34pm

    roryrabbitfield

    320 posts

    When I first pasted in that line of code, I got a huge error and no page displayed! But I realized I just need to put in the last “AND” between the last 2 categories and now everything works perfectly.

    I guess I need to get better at EE tags. I had seen an example where you could string together all the categories in a category tag, but I guess it does not work that way in the conditional tag. I do understand now.

    Thanks so much to you both. This was one of my big headaches to solve for the morning!

  • #7 / Sep 24, 2009 12:40pm

    Sue Crocker

    26054 posts

    Glad silenz was able to help. Don’t hesitate to post again as needed.

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

ExpressionEngine News!

#eecms, #events, #releases