I want to hide some attributes in the category page for certain categories, for instance 21 and 24. I tried the or statement but I guess it's not in the right position as it ignores both:
<?php $category = Mage::getModel('catalog/layer')->getCurrentCategory();
if(($category->getId()!=21) || ($category->getId()!=24)) { ?>
<strong>Capacity:</strong> <?php
echo $_product->getCapacity();
?>
<br> <strong>Graduations:</strong> <?php
echo $_product->getGraduations();
}?>
Can anyone point me in the right direction
if(($category->getId()!=21) || ($category->getId()!=24)) {
Let's see what happens here:
If the ID is 21 the "if-clause" does not pass the first expression (false) - but the ID is != 24 so it passes the second one (true). Since "||" in PHP is not an "exclusive or" it passes the whole if (false or true = true) and your attributes will be printed.
If the ID is 24 the first of clause passes (true) so the second one is ignored totally. (true or anything is always true) - The attributes will be printed.
It's just a "logic" issue - one of your "expressions" is always true since a number cannot be 21 AND 24 the same time which would cause your if-clause to skip ;)
Hint for the solution: What you want is to display the attributes when the ID is not 21 AND not 24