Page 1 of 1

N00b question, can't use if statement in User defined tag?

Posted: Fri Jun 05, 2009 11:56 am
by commadelimited
My host is using CMSMS 1.5 (puerto rico)

I have a site which features different top level sections of the site, each of which has their it's own subnav. I figured to make it easy I'd create a UDT with a case statement.

I couldn't figure how, so I tried the examples from some Smarty posts and nothing.

So since I only have 4 different sections I decided to try an if / else statement, and it keeps throwing an error. The following code:

Code: Select all

echo '<div id="subnavigation"><ul>';

{if $params['section'] eq 'aboutus'}
	echo '<li><a href="our-team.php">our team</a></li>';
	echo '<li><a href="affiliation-listing.php">affiliations</a></li>';
	echo '<li><a href="location-directions.php">location and directions</a></li>';
	echo '<li><a href="dealer-connection.php">dealer connection</a></li>';
{elseif $params['section'] eq 'products'}
	echo '<li><a href="commercial-product-lines.php">commercial product lines</a></li>';
	echo '<li><a href="residential-product-lines.php">residential product lines</a></li>';
{elseif $params['section'] eq 'dealerprograms'}
	echo '<li><a href="monthly-specials.php">monthly specials </a></li>';
	echo '<li><a href="training-classes.php">training classes</a></li>';
	echo '<li><a href="incentive-trips.php">incentive trips</a></li>';
	echo '<li><a href="forms.php">forms</a></li>';
{else}

{/if}

echo '</ul></div>';
Produces the following error:
    * Invalid code entered.
    * Parse error: syntax error, unexpected T_VARIABLE, expecting '(' in /public_html/site/admin/edituserplugin.php(103) : eval()'d code on line 3

Can someone tell me what I might be doing wrong? I've even tried the most basic if statement and got an error:

{if 1 eq 1}
echo 'howdy';
{/if}

produces:

    * Invalid code entered.
    * Parse error: syntax error, unexpected T_LNUMBER, expecting '(' in /public_html/site/admin/edituserplugin.php(103) : eval()'d code on line 1

But none of the errors tell me WHAT code is invalid.

Can someone help me out please? I'd rather have a case statement, but I don't know if this host has the proper modules?

Re: N00b question, can't use if statement in User defined tag?

Posted: Fri Jun 05, 2009 2:50 pm
by jmcgin51
you're trying to use php, but the CMSMS config file has that option turned off

try

{if 1 eq 1}
howdy
{/if}

Re: N00b question, can't use if statement in User defined tag?

Posted: Sat Jun 06, 2009 12:36 am
by commadelimited
Thanks for replying jmcgin...

Trying your snippet of code returns the following error:

    * Invalid code entered.
    * Parse error: syntax error, unexpected T_LNUMBER, expecting '(' in /public_html/site/admin/edituserplugin.php(103) : eval()'d code on line 1

Re: N00b question, can't use if statement in User defined tag?

Posted: Sat Jun 06, 2009 10:14 am
by Jeff
UDT are for PHP not Smarty, Smarty are to be used in templates

try:

Code: Select all

echo '<div id="subnavigation"><ul>';

switch ($params['section'])
{
  case ('aboutus'):
	echo '<li><a href="our-team.php">our team</a></li>';
	echo '<li><a href="affiliation-listing.php">affiliations</a></li>';
	echo '<li><a href="location-directions.php">location and directions</a></li>';
	echo '<li><a href="dealer-connection.php">dealer connection</a></li>';
        break;
  case ('products'):
	echo '<li><a href="commercial-product-lines.php">commercial product lines</a></li>';
	echo '<li><a href="residential-product-lines.php">residential product lines</a></li>';
        break;
  case ('dealerprograms'):
	echo '<li><a href="monthly-specials.php">monthly specials </a></li>';
	echo '<li><a href="training-classes.php">training classes</a></li>';
	echo '<li><a href="incentive-trips.php">incentive trips</a></li>';
	echo '<li><a href="forms.php">forms</a></li>';
        break;
default:
  break;

}

echo '</ul></div>';

Re: N00b question, can't use if statement in User defined tag?

Posted: Tue Jun 09, 2009 4:53 pm
by Pierre M.
Hello,

I'm unsure if your post is strictly on using ifs and on navigation being only an example.
I wanted to make it clear the built-in navigation/menu manager makes things much simpler : no need to code at all.
Have fun with CMSms

Pierre M.