rbarbour:
Why not just wrap the entire container in the if statement, no need for CSS
Before I comment further, I will state that there is no 'right' or 'wrong' way of achieving the desired results, but personally I tend towards using CSS for this kind of thing rather than code. I find it helps separate function from content.
Having said that, in a case like this (without having a stylesheet for each page) there is always going to be some code required anyway.
Although my original suggestion to DivaVocals was along the lines of the solution taken, in reality I probably would have opted for a slightly different method.
<?php
$style = "display:none";
if ($this_is_home_page) {
$style = "display:block !important" ;
}
echo "<style>#ez-feature-top-container-wrap {$style;}</style>";
?>
The benefit of using this method over the solution taken is that the $style variable can be initialised at the top of the page, with the actual echo/output located deeper in the code where it is actually needed/used.
Nah... I just changed my mind again :)
Something like
$useClass = "ez-feature-top-container-wrap hidden" ;
if ($this_is_home_page) {
$useClass = "ez-feature-top-container-wrap" ;
}
echo "<div class=$useClass>" ;
... stuff goes here ..
echo "</div>" ;
Then in my stylesheet.css
.ez-feature-top-container-wrap {
display: block ;
}
.ez-feature-top-container-wrap hidden {
display: none ;
}
The reason why I believe this is a better option (bearing in mind I've no real idea what is actually to be displayed) is that this allows additional control for mobile devices. For example, if the output happens to be a large banner that simply doesn't 'work' correctly on a mobile device, then another addition to the stylesheet along the lines of.................
@media (max-width: 320px) {
ez-feature-top-container-wrap {
display: none ;
}
}
.... can be used... The net result being the banner (or whatever) will only be displayed on the home page but only if the screen width is larger than 320px.
Pretty neat eh?
Cheers
RodG
NOTE: We are sorry that Rod is no longer with us.
We are grateful for all his contributions to the Zen Cart community.
Ozpost - The Ultimate Shipping module for Australian Merchants. Click these links for its Homepage, or Download from Zen-Cart.com.