cancel
Showing results for 
Search instead for 
Did you mean: 

Static block into a specific kind of page

Static block into a specific kind of page

Hi,

 

I need to show an element wrote in HTML into a footer page, only if you're in a specific page ( website homepage, category pages, search results and product pages).

 

I don't want use statics blocks because the element that I've to show is a simple image with a small amount of text, so the best way that i think to add an "if" that shows the code only if you're in the pages quoted upstairs, but I don't know how can I write the "if condition".

 

I'm waiting for the answers.

3 REPLIES 3

Re: Static block into a specific kind of page

Hi Dennis,

You can write below code into your footer.phtml file

<?php
$is_homepage = Mage::getBlockSingleton('page/html_header')->getIsHomePage();
    if($is_homepage || $this->getRequest()->getControllerName()=='category' || $this->getRequest()->getControllerName()=='product || $this->getRequest()->getControllerName() == 'result') { 
		     // your code here 
    }
?>

Re: Static block into a specific kind of page

Hi Magikvishal,

I tried to put the code into the footer page as wrote ( I added only an apex in "getControllerName" of product because I saw that it miss, also I added my static block's source code into the area that you show me) but unfortunately it doesn't work. How can I fix it?

Re: Static block into a specific kind of page

Hi Dennis, 

 

You can create the layout:

 app/design/frontend/YOUR/THEME/layout/local.xml

and add your block into the needed handlers.

 


For example, on the product page:

<catalog_product_view>
<reference name="before_body_end">
<block type="core/template" name="my.footer.template" template="PATH/TO/footer.phtml" after="-" />
</reference>
</catalog_product_view>


After that don't forget to flush cache.

 

 

Regards,
Plumrocket Team