First I am very new to Drupal but loving it more every day... Coming from Joomla I am trying to get my head thinking in a different direction.
I am making a new theme for a Drupal (just toying and learning) but coming from the Joomla world it is quite easy to do width based on variables in the manner I am use to. In Joomla I would do somehting like:
<?php
if ( mosCountModules('left')) {
$content_width = 880 - 180;
}
?>
down in the theme
<div id="body" style="width:<?php echo $content_width ?>px">
Then my content width would be 700. My problem arises when attempting use the same logic with Drupal. Since Drupal uses print() I altered my code to read
<?php
if ($sidebar_left) {
$content_width = 880 - 180;
}
?>
Problem is, it not populating <?php echo $content_width ?>px"> and if I modify it to
<?php
if (print $sidebar_left) {
$content_width = 880 - 180;
}
?>
I get what I want, but then I get data posted along the lefthand side of my screen because its reading the if exist statement. It doesn't seem to find the $sidebar_left variable alone but needs the whole (print $sidebar_left) statement.
Anyone have any ideas on how to get around the little problem? The only thing I can thing of, would be to write a wrapper, but I am hoping there is an easier way.
Comments
Try using isset()
Try using isset() like this
Thanks
I didn't even think about that... Thanks so much.
The thing is that: <?phpif
The thing is that:
Will always return true, because "print $sidebar_left" will always be true.
Not sure if isset() would work because maybe the variable is set but doesn't necessarily have any content. I don't know how drupal treats this. I think the best approach would be to use the empty() function.
Martin
Web Solutions