1. <?if(Mage::app()->getFrontController()->getRequest()->getRouteName() == 'cms' && Mage::getSingleton('cms/page')->getIdentifier() == 'home'){?>
  2. <?if($_SERVER['REMOTE_ADDR'] == '193.77.150.182'){?>
  3.  
  4. <?$cat = Mage::getModel('catalog/category')->load(17);?>
  5. <?$count = count($cat->getProductCollection());?>
  6. <script type="text/javascript">
  7. function showSub(){
  8. for(var i = 1; i <= <?=$count;?>; i++){
  9. if(i == Math.random(1-<?=$count;?>)){
  10. document.getElementById('img'+i).style.display = 'block';
  11. }else{
  12. document.getElementById('img'+i).style.display = 'none';
  13. }
  14. }
  15. }
  16. </script>
  17.  
  18. <?
  19. $rand = rand(1,$count);
  20. $i=0; foreach ($cat->getProductCollection() as $product){ $i++;?>
  21. <?$_product = new Mage_Catalog_Model_Product();?>
  22. <?$_product->load($product->getId());?>
  23. <div style="display: <?if($i==$rand) echo 'block'; else echo 'none';?>;" id="img<?=$i;?>">
  24. <center>
  25. <img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(500, 310); ?>" /><br />
  26. <?=$_product->getDescription();?>
  27. </center>
  28. </div>
  29. <?}?>
  30. <script type="text/javascript">
  31. setInterval(showSub(),1000);
  32. </script>
  33. <?}?>
  34. <?}?>