0

I have to many custom options on product page.

I would like to fill out the empty space on the left with a static block that appear only if more there is more than 4 custum options in product view.

http://goo.gl/Y7JMQf

Mad Dog Tannen
  • 7,129
  • 5
  • 31
  • 55
Italus
  • 11
  • 4

1 Answers1

0

Step1: Display the static block content using

<div class="css_class_of_container" id="ID_OF_THE_STATIC_BLOCK_CONTAINER">
    <?php 
        echo Mage::getModel('cms/block')
            ->load('STATIC_BLOCK_IDENTIFIER')
            ->toHtml();
    ?>
</div>

Step2: Add css to hide the static block container by default using

.css_class_of_container { display: none;}

Step3. Use javascript to show and hide the static block based on the number of custom options available.

in app/design/package/theme/catalog/product/view/options.phtml

<?php if (count($_options)):?>
    <script type="text/javascript">
        <?php if(count($_options) > 4):?>
            //if you are using jquery
            jQuery(document).ready(function(){
               jQuery("#ID_OF_THE_STATIC_BLOCK_CONTAINER").show();
            });
            //if using native javascript
            setTimeout('showhiddenStaticBlock()', 500);
            function showHiddenStaticBlock() {
                document.getElementById("ID_OF_THE_STATIC_BLOCK_CONTAINER").style.display = 'block';
            }
        <?php endif;?>
    </script>
<?php endif;?>
Nidheesh
  • 453
  • 4
  • 11
  • I've tried this but without success. I want to display The static block in container2 (Block after Info Column) on the left but only when I have more than 4 custom options on the right container1(Product Info Column). This will fill up the empty space on the left. – Italus Nov 22 '13 at 09:46
  • Did you check whether the content from static block is rendering? Take the html source and make sure the `
    ` is there
    – Nidheesh Nov 22 '13 at 13:17
  • fantastic!!!! to call the staticblock I've used: getLayout()->createBlock('cms/block')->setBlockId('my_static_block')->toHtml(); ?> – Italus Nov 27 '13 at 15:03