if then else

Get help with installation and running PivotX 2.0.x here. Please do not post Extension or Theme related questions here.

if then else

Postby camarados » Thu Feb 13, 2014 9:21 am

I want to show a specific sidebar by a category.
I found this code and worked with one category.

Code: Select all
[[ if $entry.category[0] == 'primeur' ]]
    [[ include file="`$templatedir`/_sub_primeur.html" ]]
[[ else ]]
      [[ include file="`$templatedir`/_sub_sidebar.html" ]]   
[[ /if ]]


But what so i have to do to make it work with more categories?

Tried this (but didnt work):
Code: Select all
[[ if $entry.category[0] == 'primeur' ]]
    [[ include file="`$templatedir`/_sub_primeur.html" ]]
[[ elseif $entry.category[0] == 'corsiva' ]]
    [[ include file="`$templatedir`/_sub_corsiva.html" ]]
[[ else ]]
      [[ include file="`$templatedir`/_sub_sidebar.html" ]]   
[[ /if ]]


Some help will be great :-)
camarados
 
Posts: 42
Joined: Tue Sep 13, 2011 8:56 am

Re: if then else

Postby hansfn » Thu Feb 13, 2014 10:47 am

Your code doesn't work if you have assigned more than one category to your entries - use in_array. See this forum post for an example.
hansfn
Developer
 
Posts: 3281
Joined: Sun Nov 25, 2007 7:48 pm
Location: Molde, Norway

Re: if then else

Postby camarados » Thu Feb 13, 2014 11:52 am

yes, most entries have more categories.
Thx, going to try that!
camarados
 
Posts: 42
Joined: Tue Sep 13, 2011 8:56 am


Return to 2.x Support Forum

Who is online

Users browsing this forum: No registered users and 3 guests

cron