goocharlton Posted September 2, 2007 Share Posted September 2, 2007 I have a content area with width that varies according to whether there are left or right modules(this is a joomla cms site). I have written this code but I cant get it to work.... <div id="content" style="width:<?php if ((mosCountModules( "left" )) < 0): if ((mosCountModules( "right" )) < 0) echo "800";; elseif ((mosCountModules( "left" )) > 0): if ((mosCountModules( "right" )) > 0) echo "380";; elseif ((mosCountModules( "left" )) < 0): if ((mosCountModules( "right" )) > 0) echo "590";; elseif ((mosCountModules( "left" )) > 0): if ((mosCountModules( "right" )) < 0) echo "590";; endif; ?>px"> </div> Can anyone tell me what I am doing wrong, if you dont know anything about Joomla do you know whats wrong with the php i have writen?. I am trying to say that: - If there are no modules in the left AND right columns echo a width of 800px. - If there are modules in the left AND right columns echo a width of 380px. - If there are modules in the right AND not in the left columns echo a width of 590px. - If there are modules in the left AND not in the right columns echo a width of 590px. Quote Link to comment Share on other sites More sharing options...
matthewhaworth Posted September 2, 2007 Share Posted September 2, 2007 I have a content area with width that varies according to whether there are left or right modules(this is a joomla cms site). I have written this code but I cant get it to work.... <div id="content" style="width:<?php if ((mosCountModules( "left" )) < 0): if ((mosCountModules( "right" )) < 0) echo "800";; elseif ((mosCountModules( "left" )) > 0): if ((mosCountModules( "right" )) > 0) echo "380";; elseif ((mosCountModules( "left" )) < 0): if ((mosCountModules( "right" )) > 0) echo "590";; elseif ((mosCountModules( "left" )) > 0): if ((mosCountModules( "right" )) < 0) echo "590";; endif; ?>px"> </div> Can anyone tell me what I am doing wrong, if you dont know anything about Joomla do you know whats wrong with the php i have writen?. I am trying to say that: - If there are no modules in the left AND right columns echo a width of 800px. - If there are modules in the left AND right columns echo a width of 380px. - If there are modules in the right AND not in the left columns echo a width of 590px. - If there are modules in the left AND not in the right columns echo a width of 590px. <div id="content" style="width:<?php if ((mosCountModules( "left" )) < 0) { if ((mosCountModules( "right" )) < 0) echo "800"; } elseif ((mosCountModules( "left" )) > 0) { if ((mosCountModules( "right" )) > 0) echo "380"; } elseif ((mosCountModules( "left" )) < 0) { if ((mosCountModules( "right" )) > 0) echo "590"; } elseif ((mosCountModules( "left" )) > 0) { if ((mosCountModules( "right" )) < 0) echo "590";; } ?>px"> </div> Your syntax was completely wrong? Quote Link to comment Share on other sites More sharing options...
hostfreak Posted September 2, 2007 Share Posted September 2, 2007 <div id="content" style="width:<?php if ((mosCountModules( "left" )) < 0) { if ((mosCountModules( "right" )) < 0) echo "800"; } elseif ((mosCountModules( "left" )) > 0) { if ((mosCountModules( "right" )) > 0) echo "380"; } elseif ((mosCountModules( "left" )) < 0) { if ((mosCountModules( "right" )) > 0) echo "590"; } elseif ((mosCountModules( "left" )) > 0) { if ((mosCountModules( "right" )) < 0) echo "590";; } ?>px"> </div> Your syntax was completely wrong? Umm... no, his syntax was not completely wrong. I suggest you look into http://www.php.net/manual/en/control-structures.alternative-syntax.php . However, his logic is. Try this: <div id="content" style="width:<?php if ((mosCountModules('left') && mosCountModules('right')) < '0'): echo '800'; elseif ((mosCountModules('right') && mosCountModules('left')) > '0'): echo '380'; elseif ((mosCountModules('left') < '0') && (mosCountModules( "right" ) > '0')): echo '590'; elseif ((mosCountModules('right') < '0') && (mosCountModules( "left" ) > '0')): echo '590'; endif; ?>px"> </div> Quote Link to comment Share on other sites More sharing options...
Timma Posted September 2, 2007 Share Posted September 2, 2007 Just wondering, but don't you have to cut a gaping hole? <<If wondering what the hell I am on about, look for the quotation marks>> echo "<div id='content' style='width:"<?php if ((mosCountModules('left') && mosCountModules('right')) < '0'): echo '800'; elseif ((mosCountModules('right') && mosCountModules('left')) > '0'): echo '380'; elseif ((mosCountModules('left') < '0') && (mosCountModules( "right" ) > '0')): echo '590'; elseif ((mosCountModules('right') < '0') && (mosCountModules( "left" ) > '0')): echo '590'; endif; ?>"px'> </div>"; Quote Link to comment Share on other sites More sharing options...
hostfreak Posted September 3, 2007 Share Posted September 3, 2007 Timma, what exactly are you talking about (cut a gaping hole)? Quote Link to comment Share on other sites More sharing options...
Timma Posted September 3, 2007 Share Posted September 3, 2007 No idea, I must of picked it up somewhere. Probably is unneeded as people, with strings, usually do something like. "text goes here $var oh look more text" and I go "text goes here ".$var." oh look more text" Quote Link to comment Share on other sites More sharing options...
hostfreak Posted September 3, 2007 Share Posted September 3, 2007 PHP can be embedded in html, so there is no problem with the way he's doing it. Take a look at http://www.php.net/manual/en/language.basic-syntax.php & http://www.php.net/manual/en/language.types.string.php . Hopefully those will give you a better understanding. Your method is fine for strings (<a href="http://www.php.net/manual/en/language.operators.string.php">concatenation operator</a>), but that is kinda irrelevant to this topic. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.