$value)
{
// If position has modules
if (JFactory::getDocument()->countModules($name))
{
// Increase active positions count
$countOfActivePositions++;
$totalWidth = $totalWidth + $value;
}
}
if ($countOfActivePositions > 1)
{
// For Bootstrap with equal widths use
// $width = "col-md-".(12 / $countOfActivePositions);
// For Custom with equal widths use
// $width = (100 / $countOfActivePositions);
}
foreach($position as $name => $value)
{
if ($value > 0)
{
$width = $value;
}
if ($totalWidth < 100)
{
// For Bootstrap remove/comment the $width bellow
// For custom with equal widths add/uncomment the $width bellow
// For custom with proporcional widths add/uncomment the $width bellow
// $width=$value*100/$totalWidth;
// For Bootstrap with proporcional widths add/uncomment the $width bellow
// For Bootstrap with equal widths add/uncomment the $width bellow
$width = 'col-md-' . round($value * 12 / $totalWidth);
}
/**
// For Bootstrap with proporcional widths remove/comment the IF bellow
// For Custom with with more then 1 position add/uncomment the IF bellow
if (($value > 0) and ($countOfActivaPositions == 2) and (count($position) > 2))
{
$width = 100 / 2;
}
// For Bootstrap with proporcional widths remove/comment the IF bellow
// For Custom with with more then 1 position add/uncomment the IF bellow
if (($value > 0) and ($countOfActivePositions == 3) and (count($position) > 3))
{
$width = 100 / 3;
}
// For Bootstrap with proporcional widths remove/comment the IF bellow
// For Custom with with more then 1 position add/uncomment the IF bellow
if (($value > 0) and ($countOfActivePositions == 4) and (count($position) > 4))
{
$width = 100 / 4;
}
*/
if (JFactory::getDocument()->countModules($name))
{
// For Bootstrap use
echo '
';
// For Custom Width use
// echo '
';
}
}
}
// For Bootstrap use the grid divisions by 12 in the width keys like this: 1,2,3,4,5,6,7,8,9,10,11
// Then use the code like this bellow
// echo positions(array('menu' => 4, 'login' => 6, 'nada' => 2), 'block');
// If You wish to use with equal percentages FOREVER use the code like this bellow
// echo positions(array('menu', 'login', 'nada'), 'block');
// If You wish to use with custom percentages use the code like this bellow
// echo positions(array('menu' => 60, 'login' => 20, 'nada' => 20), 'block');
?>
countModules('menu', 'login', 'nothing')): ?>
4,
'search' => 1,
'nothing' => 6
) , 'block');
?>