I am making a responsive joomla template, but i am stucked in a problem.
i have four module position: header1, header2, header3, header4 if there is only position active , then its class will be 'col12' & 'last'
if two position then class will be 'col6' for both position and class 'last' only for last position
if there position then class 'three' for all positions and class 'last' for the last position
how do i do this in array ?? any good solution for doing this
currently i am using this but not working properly or please tell me the block system that was used in JAT3 framework how can i make my own block system for my template like jat3
if($header1 && $header2 && $header3 && $header4 > 0){
$hCols='three';
}elseif($header1 && $header2 && $header3 > 0){
$hCols='four';
$h3last='last';
}elseif($header1 && $header2 > 0){
$hCols='six';
$h2last='last';
}elseif($header1 > 0){
$hCols='twelve';
$h1last='last';
}
You probably meant to check that all the values are not null (I'd prefer using isset
) - but you're actually checking only the last value in every if
, you can do:
if($header1 > 0 && $header2 > 0 && $header3 > 0 && $header4 > 0){
$hCols='three';
}elseif($header1 > 0 && $header2 > 0 && $header3 > 0){
$hCols='four';
$h3last='last';
}elseif($header1 > 0 && $header2 > 0){
$hCols='six';
$h2last='last';
}elseif($header1 > 0){
$hCols='twelve';
$h1last='last';
}
You can also do it (which might be your originally intention) using only one &
(bitwise operator):
if($header1 & $header2 & $header3 & $header4 > 0){
$hCols='three';
}elseif($header1 & $header2 & $header3 > 0){
$hCols='four';
$h3last='last';
}elseif($header1 & $header2 > 0){
$hCols='six';
$h2last='last';
}elseif($header1 > 0){
$hCols='twelve';
$h1last='last';
}