Multiple page problems

Questions and answers about ShopSite Custom Templates

Multiple page problems

Postby queenofangels » Tue Jun 19, 2012 12:04 pm

Is there a way to make this work?? <tr>
<td>
[-- IF PAGE.NAME "A" --]
[-- ELSE_IF PAGE.NAME "B" --]
[-- ELSE_IF PAGE.NAME "C" --]
HTML CODE HERE
[-- ELSE --]
[-- IF PAGE.NAME "D" --]
[-- ELSE_IF PAGE.NAME"E" --]
[-- ELSE_IF PAGE.NAME "F" --]
DIFFERENT HTML CODE HERE
[-- END_IF --]
[-- END_IF --]
</td>
</tr>
I'm trying to create an "OR' statement, if that's possible. :( :(
queenofangels
 
Posts: 78
Joined: Tue May 24, 2011 5:36 pm

Re: Multiple page problems

Postby Jim » Tue Jun 19, 2012 12:58 pm

Sorry, there isn't an OR statement.

I don't think the code wouldn't work like you have it. I don't think the syntax for IF - ELSE - ELSE_IF - END_IF allows an ELSE in the middle of a number of ELSE_IFs and then continue with the ELSE_IF statements.

Here is how I would go about this. Assuming you have just 2 types of page each using one of the different code sections.
Use one of the custom fields to set a value to indicate which type of code to use for the page Then instead of having the multiple ELSE_IF statements you could just check the value of the extra page field and output the code for the appropriate type.
Code: Select all
<tr>
<td>
[-- IF PAGE.FIELD1 "X" --]
    HTML CODE HERE
[-- ELSE --]
   DIFFERENT HTML CODE HERE
[-- END_IF --]
</td>
</tr>

If you want to make it a little more robust just in case someone forgets to put a value in Page.field1 and you want something different output then you could add a default value if neither of the code sections are specified
Code: Select all
<tr>
<td>
[-- IF PAGE.FIELD1 "X" --]
    HTML CODE HERE
[-- ELSE --]
    [-- IF PAGE.FIELD1 "Y" --]
          DIFFERENT HTML CODE HERE
    [-- ELSE --]
        it isn't either so have some other code you might want to use.
    [-- END_IF --]
[-- END_IF --]
</td>
</tr>
Jim
Site Admin
 
Posts: 4953
Joined: Fri Aug 04, 2006 1:42 pm
Location: Utah

Re: Multiple page problems

Postby queenofangels » Tue Jun 19, 2012 5:32 pm

Thanks Jim,
What you have suggested will work great :D :D Thanks
queenofangels
 
Posts: 78
Joined: Tue May 24, 2011 5:36 pm


Return to Custom Template Questions

Who is online

Users browsing this forum: No registered users and 117 guests