Page 1 of 1

how do I use else_if function [solved]

Posted: Tue Jan 05, 2010 8:51 am
by mvandiermen
I am trying to get this to work http://wiki.cmsmadesimple.org/index.php ... re#else_if

I suppose I use this as a User Defined Tag; but when I try it says

Invalid code entered.
Parse error: syntax error, unexpected ';' in /home/content/w/e/b/webdesign678/html/northshoredrama.com.au/admin/adduserplugin.php(100) : eval()'d code on line 2

I pasted this in to a GCB

Code: Select all

global $gCms;
$thispage = ;
$thispage = $gCms->variables['page_name'];
if ($thispage == "pagename")  echo "this is for pagename";
elseif  ($thispage == "othername") echo "this is for othername";
elseif  ($thispage == "npage") echo "you can have as many elseif clauses you want";
else echo "default text";
Then added {global_content name='elseif'} to the template

But when I go to index.php?page=pagename that did not work.

I have no idea; but maybe I have to add something to "$thispage = ;" ?

Any example of how I use this would be kindly appreciated

Re: how do I use else_if function [solved]

Posted: Tue Jan 05, 2010 11:03 am
by mvandiermen
it worked ok after I removed the second line
$thispage = ;

error message gave it away, I should have tried this before

Code: Select all

global $gCms;
$thispage = $gCms->variables['page_name'];
if ($thispage == "pagename")  echo "this is for pagename";
elseif  ($thispage == "othername") echo "this is for othername";
elseif  ($thispage == "npage") echo "you can have as many elseif clauses you want";
else echo "default text";