0

I want to show a static block only on the catalogsearch page. My catalogsearch page is the same layout as 2columns-left.phtml. I don't really want to make another layout for the catalogsearch. Is there a way that i can show the static block only on the catalogsearch page ?

  • Did you checked catalogsearch.xml? – Suresh Chikani May 8 '18 at 7:14
  • Yes, but how can i set the place the banner will show up there. I want it to show up below the header but above the content of the search... – Jasper1187 May 8 '18 at 7:26
0

Use below code in 2columns-left.phtml.phtml after

<?php echo $this->getChildHtml('header') ?> 

this with your block identifier:

<?php 
     $route=$this->getRequest()->getRouteName();
     $controller=$this->getRequest()->getControllerName();
     $action=$this->getRequest()->getActionName();
    if($route=='catalogsearch' && $controller=="result" &&   $action=='index'){
       $this->getLayout()->createBlock('cms/block')->setBlockId('block_identifier')->toHtml() ;
    }
?>
  • Thank you, i found the file. The problem now is that it shows in the content side of the 2columns-left. So the banner is not 100%, because it is in: colmain. I need to have it cover the leftbar and col main, so it should be above those 2. – Jasper1187 May 8 '18 at 7:41
  • check modified answer – Prasanta Hatui May 8 '18 at 8:06
  • Thank you very much, had to add 'echo' before the static block code, but after that it worked like a charm! – Jasper1187 May 8 '18 at 8:23

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.