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

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
commadelimited
New Member
New Member
Posts: 2
Joined: Fri Jun 05, 2009 4:01 am

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

Post 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?
jmcgin51
Power Poster
Power Poster
Posts: 1899
Joined: Mon Jun 12, 2006 9:02 pm

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

Post 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}
commadelimited
New Member
New Member
Posts: 2
Joined: Fri Jun 05, 2009 4:01 am

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

Post 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
Jeff
Power Poster
Power Poster
Posts: 961
Joined: Mon Jan 21, 2008 5:51 pm

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

Post 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>';
Pierre M.

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

Post 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.
Post Reply

Return to “CMSMS Core”