Jump to content

How do I control which blocks show on which pages?


Recommended Posts

I have version 1.5 and would like to have some blocks show on the front page only. For example, I'd like the "new products" block and the "viewed products" block to show on the front page and NOT show on any other pages.

 

How (specifically) do I set this up.

 

Thank you

Link to comment
Share on other sites

Thank you Clayton...That worked for some pages. I still get New Products and Viewed Products blocks showing on "Your Shopping Cart" Page and the payment page. Say I pay by Check. When that page comes up, the Viewed and New Products blocks are on the right side. I went back to modules as you instructed but I find no entry for these?????

 

Any further suggestions?

Edited by huntleybill (see edit history)
Link to comment
Share on other sites

Let's take blocknewproducts.tpl in modules>blocknewproducts

 

This is the code inside it:

 

<!-- MODULE Block new products -->
<div id="new-products_block_right" class="block products_block">
<h4><a href="{$link->getPageLink('new-products')}" title="{l s='New products' mod='blocknewproducts'}">{l s='New products' mod='blocknewproducts'}</a></h4>
<div class="block_content">
{if $new_products !== false}
 <ul class="product_images clearfix">
 {foreach from=$new_products item='product' name='newProducts'}
  {if $smarty.foreach.newProducts.index < 2}
<li{if $smarty.foreach.newProducts.first} class="first"{/if}><a href="{$product.link}" title="{$product.legend|escape:html:'UTF-8'}"><img src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'medium_default')}" height="{$mediumSize.height}" width="{$mediumSize.width}" alt="{$product.legend|escape:html:'UTF-8'}" /></a></li>
  {/if}
 {/foreach}
 </ul>
 <dl class="products">
 {foreach from=$new_products item=newproduct name=myLoop}
  <dt class="{if $smarty.foreach.myLoop.first}first_item{elseif $smarty.foreach.myLoop.last}last_item{else}item{/if}"><a href="{$newproduct.link}" title="{$newproduct.name|escape:html:'UTF-8'}">{$newproduct.name|strip_tags|escape:html:'UTF-8'}</a></dt>
  {if $newproduct.description_short}<dd class="{if $smarty.foreach.myLoop.first}first_item{elseif $smarty.foreach.myLoop.last}last_item{else}item{/if}"><a href="{$newproduct.link}">{$newproduct.description_short|strip_tags:'UTF-8'|truncate:75:'...'}</a><br /><a href="{$newproduct.link}" class="lnk_more">{l s='Read more' mod='blocknewproducts'}</a></dd>{/if}
 {/foreach}
 </dl>
 <p><a href="{$link->getPageLink('new-products')}" title="{l s='All new products' mod='blocknewproducts'}" class="button_large">» {l s='All new products' mod='blocknewproducts'}</a></p>
{else}
 <p>» {l s='No new products at this time' mod='blocknewproducts'}</p>
{/if}
</div>
</div>
<!-- /MODULE Block new products -->

 

Simply change it with the one below

 

<!-- MODULE Block new products -->
{if $page_name == 'index'}
<div id="new-products_block_right" class="block products_block">
<h4><a href="{$link->getPageLink('new-products')}" title="{l s='New products' mod='blocknewproducts'}">{l s='New products' mod='blocknewproducts'}</a></h4>
<div class="block_content">
{if $new_products !== false}
 <ul class="product_images clearfix">
 {foreach from=$new_products item='product' name='newProducts'}
  {if $smarty.foreach.newProducts.index < 2}
<li{if $smarty.foreach.newProducts.first} class="first"{/if}><a href="{$product.link}" title="{$product.legend|escape:html:'UTF-8'}"><img src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'medium_default')}" height="{$mediumSize.height}" width="{$mediumSize.width}" alt="{$product.legend|escape:html:'UTF-8'}" /></a></li>
  {/if}
 {/foreach}
 </ul>
 <dl class="products">
 {foreach from=$new_products item=newproduct name=myLoop}
  <dt class="{if $smarty.foreach.myLoop.first}first_item{elseif $smarty.foreach.myLoop.last}last_item{else}item{/if}"><a href="{$newproduct.link}" title="{$newproduct.name|escape:html:'UTF-8'}">{$newproduct.name|strip_tags|escape:html:'UTF-8'}</a></dt>
  {if $newproduct.description_short}<dd class="{if $smarty.foreach.myLoop.first}first_item{elseif $smarty.foreach.myLoop.last}last_item{else}item{/if}"><a href="{$newproduct.link}">{$newproduct.description_short|strip_tags:'UTF-8'|truncate:75:'...'}</a><br /><a href="{$newproduct.link}" class="lnk_more">{l s='Read more' mod='blocknewproducts'}</a></dd>{/if}
 {/foreach}
 </dl>
 <p><a href="{$link->getPageLink('new-products')}" title="{l s='All new products' mod='blocknewproducts'}" class="button_large">» {l s='All new products' mod='blocknewproducts'}</a></p>
{else}
 <p>» {l s='No new products at this time' mod='blocknewproducts'}</p>
{/if}
</div>
</div>
{/if}
<!-- /MODULE Block new products -->

 

I added if condition just after and before <!-- /MODULE Block new products --> tags.

Edited by Caglar (see edit history)
Link to comment
Share on other sites

×
×
  • Create New...