Controlling how static blocks are displayed in Magento

Want to learn something new? Check out my most recent Egghead course:

Build a Twelve-Factor Node.js App with Docker - WATCH NOW on!

Cheers -Mark

Wed, 06/29/2011 - 15:41

Submitted by markoshust Wed, 06/29/2011 - 15:41

To disable a static block globally, go to CMS > Static Blocks > Select One > set Status = Disabled > Save To control the disable of static blocks on various pages, to go CMS > Widgets > Select One > Reference 'Layout Updates' section To remove a specific block for a specific page, go to CMS > Pages > Manage Content > Select One > Click the currently published Revision number on the initial page > Click the Design tab on the left > In the Layout XML section paste in the appropriate block of code dependent on the block you want to remove, for example to unset everything from the left sidebar:

To unset a certain static block (named name_of_block) from the right sidebar:


You can find the id of the static block by going to CMS > Static Blocks and looking up the value in the column Identifier.


Thanks for the code but it does not appear to be working. I have input in the Layout Update XML field but has no effect. Anybody help?

Hi Mark, I'm doing a task where I need to replace Mage_CatalogSearch. Where do I store the search results so that content blocks could access the variable. For instance the search result is to be stored in a string variable. Can I introduce a new property on the $this variable through the controller and the block will access it through $this, too? For example in my controller: $this->search_results = "results"; Then in my block will be:

You will need to use PHP's magic setter and getter methods. In your controller: $this->setSearchResults("results"); then in your block: echo $this->getSearchResults(); These magic methods are built into PHP for just this purpose. Good luck :)

I want to know the concept behind the block in magento,how they really work!!!!

Mark, Thanks for these tips. I've removed the default static blocks from my site and created a new block which I plan to use multiple times in my homepage. In each block I want to use a different header title, so I created a variable "block_header" and added it to the static block. I've successfully added the static block to my CMS home page via XML, but I can't figure out how to pass in the header variable to the block. Any help would be much appreciated. Steve

I managed to get some time today to get the new article on creating custom variables in Magento... check it out! Creating custom layout files and variables in Magento blocks and templates

hi Mark, is there are way to control a static block from frontend. so to give the ability for the user to click something and for this to enable a static block and so turn on what ever i load into that block. the location of block can already be set in the xml.

Not sure I understand your question... seems like you'd need to custom code a module for it though. This article just outlines basic control flow.

Hi Marc, Can I display two static blocks in the left side bar? I want to add a twitter widget AND a custom made mail chimp newsletter block. I created the block and can make the left side bar to show either the twitter or the newsletter block but not both. I can display the twitter and custom magento newsletter but don't want this one so disabled it. What code do I use in the catalog.xml to change this?

Is it also possible to remove some static blocks out of the footer of the homepage?Thanks in advance

Hi,is it also possible to remove the footer block from the homepage only? So pecify the static block to display on specific pages only?Thanks in advance