Category Conditional

Discussion in 'Templates, HTML, CSS, and Design Help' started by blackorange, Jan 8, 2012.

  1. blackorange Member

    Hi,

    Does anyone know if there is a Smarty conditional for specific categories? I.e.

    If CATEGORY = THIS_CAT
    THEN...
    ELSE...
    END...

    Thanks
    Tom
  2. seymourjames All Hands On Deck

    Use the smarty debug debug console (lots of posts about that on the forum) to find out if a category variable is available to the specific template file where you wish to make a test. You then make a straightforward smarty test on that variable (lots of examples in your template files on how to create smarty tests).
  3. freeze2 Customer

    A little rabbit trail from this particular post...

    Useing an if statement such as the following:

    Code:
    {if $categoryname == "My Category"}Cool, this works!{elseif $categoryname == "Your Category"}Nope, doesn't work{else}Nice try{/if}
    Is there a limit to how many {elseif}'s you can use...basically what I'm wanting to know is can you overtax your server resourses if you use too many or doesn't it really make any difference if you use 1 or say 50 ?
  4. seymourjames All Hands On Deck

    First of all that code will not work on many template files but will work on some. The point is to understand the coding process and the use of the smarty debug console. If not the person learns nothing.

    Well thousands of test yes but a few dozen no. You would not even see the difference.
  5. freeze2 Customer

    Thanks very much!
  6. blackorange Member

    Thanks!

    categoryname didn't seem to work for me, but categoryid did...

    Tom
  7. seymourjames All Hands On Deck

    Did you use the debug console? If you did then you will see why this is an indispensable tool for modifying your templates.

Share This Page