how do I use else_if function [solved]

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
mvandiermen
Forum Members
Forum Members
Posts: 83
Joined: Mon Nov 03, 2008 1:28 pm

how do I use else_if function [solved]

Post 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
Last edited by Anonymous on Tue Jan 05, 2010 11:03 am, edited 1 time in total.
mvandiermen
Forum Members
Forum Members
Posts: 83
Joined: Mon Nov 03, 2008 1:28 pm

Re: how do I use else_if function [solved]

Post 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";
Post Reply

Return to “Developers Discussion”