Categories > TinyButStrong general >

if then statement in HTML

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: austin
Date: 2005-02-18
Time: 00:45

if then statement in HTML

I am trying to display a menu based on a variable.
If menu=Projects, the Projects menu would display.
If menu=Press, the Press menu would display.
If menu=Contacts, the Contacts menu would display.

Here is the html that obviously does not work:
[var.menu;if [val]='Projects']
[onload;tplvars;submenu_link1=Crow Residence]
[onload;tplvars;submenu_link2=Oceanfront Residence]
[onload;tplvars;submenu_link3=Lovitt Residence]

            <a href="project01-01.php">[var..tplvars.submenu_link1]</a><br>
                    <a href="project02-01.php">[var..tplvars.submenu_link2]</a><br>
                    <a href="project03-01.php">[var..tplvars.submenu_link2]</a><br>
[/if]

[var.menu;if [val]='Press']
[onload;tplvars;submenu_link1=Newspaper]
[onload;tplvars;submenu_link2=Television]
[onload;tplvars;submenu_link3=Radio]

                <a href="press-01.php">[var..tplvars.submenu_link1]</a><br>
                    <a href="press-02.php">[var..tplvars.submenu_link2]</a><br>
            <a href="press-03.php">[var..tplvars.submenu_link3]</a><br>
[/if]

[var.menu;if [val]='Contact']
[onload;tplvars;submenu_link1=About Us]
[onload;tplvars;submenu_link2=Address]
[onload;tplvars;submenu_link3=Email]

                <a href="contact-01.php">[var..tplvars.submenu_link1]</a><br>
                    <a href="contact-02.php">[var..tplvars.submenu_link2]</a><br>
            <a href="contact-03.php">[var..tplvars.submenu_link3]</a><br>
[/if]
By: Skrol29
Date: 2005-02-18
Time: 02:03

Re: if then statement in HTML

Hello Austin,

Here is an example of how you can do it.
I've just not used the 'tplvar' parameters because there is no use so far.
But if you need them, you can add them just the way you did.

<div>
  [onload_menu;block=div;when [var.menu]='Projects']
  <a href="project01-01.php">Crow Residence</a><br>
  <a href="project02-01.php">Oceanfront Residence</a><br>
  <a href="project03-01.php">Lovitt Residence</a><br>
</div>
<div>
  [onload_menu;block=div;when [var.menu]='Press']
  <a href="press-01.php">Newspaper</a><br>
  <a href="press-02.php">Television</a><br>
  <a href="press-03.php">Radio</a><br>
</div>
...
By: Skrol29
Date: 2005-02-18
Time: 02:05

Re: if then statement in HTML

PS: parameter 'if' is for fields, parameter 'when' is for blocks.