Coen Adriaanse
Coen Adriaanse

Reputation: 13

Magento Category id array on attribute

I have a site running on Magento and i have build some hand made code onto the view.phtml and list.phtml

<?php $category = Mage::getModel('catalog/layer')->getCurrentCategory();?>
<?php if($category->getId()==80): ?>
    Command what to do
<?php else: ?>
    Else command this
<?php endif; ?>

What i would like to make is to check more categories ( like eg. 80,81 ) before echo it. How do i have to change the code?

Upvotes: 1

Views: 784

Answers (1)

ThiefMaster
ThiefMaster

Reputation: 318518

Use in_array()

<?php if(in_array($category->getId(), array(80, 81, ...))): ?>

If you want different code for the various categories:

<?php if($category->getId()==80): ?>
    ...
<?php elseif($category->getId()==81): ?>
    ...

Upvotes: 2

Related Questions