Hi, can anyone tell me why my function isn’t working?
Simply put it;
counts how many modules are published (from a joomla template)
sets a module width
outputs the html
The code works fine when i use it via an include, but when i try to put it into a function, the page stops loading when it gets to the function call… Can anyone tell me why this is happening?
<?php
$var = modWidth($row, $siteWidth);
echo $var;
<?php
function modWidth($row, $siteWidth)
{
$published = 0;
$array = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H');
// Calculates how many modules are published to row
foreach($array as $position)
{
if($this->countModules('topRow' . $row . '_' . $position))
{
$published = $published+1;
}
}
// Sets module width according to number published
$pixelsUsed = $published * 15;
$pixelsLeft = $siteWidth - $pixelsUsed;
$modWidth = $pixelsLeft / $published;
// Outputs published modules
foreach ($array as $position)
{
if($this->countModules('topRow' . $row . '_' . $position))
{?>
<div id="<?php echo'topRow' . $row . '_' . $position?>" class="modRow" style="width:<?php echo $modWidth;?>px;">
<jdoc:include type="modules" name="<?php echo'topRow' . $row . '_' . $position?>" style="xhtml" />
</div>
<?php
}
}
}