1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

If statement for parent categories

Discussion in 'Templates, HTML, CSS, and Design Help' started by jason1971, Jun 29, 2014.

  1. jason1971 Customer

    Hi all,

    I hope my rambling will make sense to you.

    Is there a way to use a statement which can call all the subcategories from their main parent category without using lots of elseif statements ?

    Say I have 5 parent categories and they each have 10 sub-categories. and I want to add different text to each of the 5 parents sub-categories. Is there a statement or something I can use to say
    if all subcategories under parent category1 add this text.
    if all subcategories under parent category2 add this text. etc..

    Does that make sense ? (Mmm best not answer that:confused: )

    Cheers anyway for any assistance offered

    Jason
  2. Mike-N-Tosh Owner

  3. jason1971 Customer

    lol sorry Mike. difficult to explain what I mean I guess.

    attempt 2.

    Say I wanted to add something like text to all the subcategories under 1 particular parent category, so that whenever one of subcategories appears on the showlings page this text appears.

    But instead of having to put {if $categoryid=="2"} text {elseif $categoryid=="3"} test etc... I could add something like {if $categoryid=="2","3","4"}text

    any better ? :D Think my head is going to fall off
  4. Mike-N-Tosh Owner

    I'm a little unsure why/how you are using this to begin with. Assuming from your post that you are "Browsing" by category that would mean that you are actually using the "browse.tpl" template AND if "showlistings" is set to on/true, then it will also include the showlistings(2).tpl file as well.

    If that is indeed the case then you are makeing this much more difficult than you need to. Just simply fill in the "Promotional Category Text" field in your categories and it will show that in the browse.tpl file. (look for the {$promo} field)

    Otherwise...

    I haven't tested this, but you could try
    Code:
    {if in_array($categoryid, array(2,3,4))}
      text
    {elseif in_array($categoryid, array(5,6,7))}
      blah, blah...
    {/if}

Share This Page