0

Created CMS > Block and display it on product page as tabs following this tutorial

app/design/frontend/[theme]/default/layout/catalog.xml

<block type="catalog/product_view_attributes" name="product.sizes" as="sizes" template="catalog/product/view/sizes.phtml">
    <action method="addToParentGroup"><group>detailed_info</group></action>
    <action method="setTitle" translate="value"><value>Size Guide</value></action>
</block>

From the above code, block title is set from admin and it will be shown as product tab even if its disabled from admin end.

  1. How can we show block only if its enabled from admin and check using some IF condition in xml ?

Also is it possible to show the title given from admin end rather than setting it from XML file ?

1

I am not sure if you can do it via XML. But modifying .phtml file you surely can show/hide the Tabs.
File to edit:

app/design/frontend/rwd/[your-theme]/template/catalog/product/view.phtml

And update the following block of code:

<div class="product-collateral toggle-content tabs">
    <?php if ($detailedInfoGroup = $this->getChildGroup('detailed_info', 'getChildHtml')):?>
        <dl id="collateral-tabs" class="collateral-tabs">
            <?php foreach ($detailedInfoGroup as $alias => $html):?>
                <!-- Edit Starts -->
                <?php
                if ($alias == 'sizes') {
                    $shouldHideSizeTab = false; # @todo add some condition on which it will hide
                    if ($shouldHideSizeTab) {
                        continue; # escapes size tab
                    }
                }
                ?>
                <!-- Edit Ends -->
                <dt class="tab"><span><?php echo $this->escapeHtml($this->getChildData($alias, 'title')) ?></span></dt>
                <dd class="tab-container">
                    <div class="tab-content"><?php echo $html ?></div>
                </dd>
            <?php endforeach;?>
        </dl>
    <?php endif; ?>
</div>
  • The tab should hide if status is diabled from admin. How can I implement in aobve code ? – Slimshadddyyy Feb 17 '15 at 7:35
  • What's the path (xml) to your settings? – MagePsycho Feb 17 '15 at 17:25

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.