1

My client wants to change the default title "More Views" for additional images that appear under the main image on individual product pages. The client offers combo packages, and wants that title to read "Included Products" only on combo package product pages.

I've edited the following relevant code in app/design/frontend/base/default/template/catalog/product/view/media.phtml as follows:

<?php if (count($this->getGalleryImages()) > 0): ?>
<div class="more-views">
<?php
    if($category->getID()==12):
?>
<h2><?php echo $this->__('Included Products') ?></h2>
<?php endif; ?>
<h2><?php echo $this->__('More Views') ?></h2>
<ul>
<?php foreach ($this->getGalleryImages() as $_image): ?>
<li>
    <a href="#" onclick="popWin('<?php echo $this->getGalleryUrl($_image) ?>', 'gallery', 'width=300,height=300,left=0,top=0,location=no,status=yes,scrollbars=yes,resizable=yes'); return false;" title="<?php echo $this->escapeHtml($_image->getLabel()) ?>"><img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize(56); ?>" width="56" height="56" alt="<?php echo $this->escapeHtml($_image->getLabel()) ?>" /></a>
</li>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>

The current result is that the "More Views" div does not display at all. No exceptions appears in var/log. Also, I'm not altogether certain I should be changing this code here as it may be "hacking core." Any thoughts are appreciated.

I'm running Magento CE 1.8.1.0.

0

I think the problem is your $category variable. It is not defined and that makes your if condition always false. This makes following code 'disappear'.

So remove the if statement from your code and replace this part of you page

<h2><?php echo $this->__('More Views') ?></h2>

with the following code.

<?php

    $categoryIds = $_product->getCategoryIds();//collect category ids of product
    if(in_array(12,$categoryIds)): //check whether product belong to category 12
?>
        <h2><?php echo $this->__('Included Products') ?></h2>
<?php else:    ?>

         <h2><?php echo $this->__('More Views) ?></h2>
<?php endif;    ?>

I think this will solve your issue. Remove the comments that I provided if you don't need it. I just added it for the sake of understanding the code.

Note: This removes only your header More Views and not its contents.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.