Static blocks in Magento are a useful way of making elements of your site easily configurable by administrators. If you have sidebar blocks, headers or other elements that can change from time to time, using a static block can be easier in the long run than hard-coding them.

Static blocks are very simple to create. In the admin backend, just go to the CMS menu and select Static Blocks. Click on the Add New Block button to create a new block. The fields for a static block are also very simple - you can give the block a title (used to distinguish blocks in the backend) and you can select whether it is enabled or not. The Content field is where you can enter your block HTML. You can use Magento template placeholders in this field (i.e. https://static.fontis.com.au/skin/frontend/base/default/...).

The Identifier field assigns the block a name that Magento will use to refer to it. You can also select what store views the block will appear in. You can combine this with the Store Views field to create different versions of a block for different stores. For example, say you have two different store views for two different countries (e.g. Australia and the US), and you have a block containing contact details that vary from country to country (such as phone numbers). If you create a block with the identifier 'contact' and set its store view to the Australian store view, then create a second block that also has the identifier 'contact' but set its store view to the US store, the appropriate block will be used on each store.

Once you have created a static block, you need to tell Magento to actually put it somewhere. Certain other Magento configuration sections can use static blocks (such as the catalog category properties, as seen in the Magento static blocks screencast), but you can also include them directly in a number of other ways.

If you want to include a static block inside another static block or CMS page, you can use a Magento template placeholder (replace 'IDENTIFIER' with the static block identifier):


...
This is some CMS page text. A static block goes below this:
{{block type="cms/block" block_id="IDENTIFIER"}}
More text after the block...
...

You can also include a static block from a layout XML file (replace 'BLOCK_NAME' and 'IDENTIFIER' with appropriate values - the block name just needs to be unique). If you open any Magento layout files, you can see where the blocks are defined; you can add your own blocks after the existing ones. The 'before' and 'after' attributes indicates where your static block appears relative to other blocks in the same layout section.

...
 <block type="cms/block" name="BLOCK_NAME" after="cart_sidebar">
 <action method="setBlockId"><block_id>IDENTIFIER</block_id></action>
 </block>
...

Finally, you can include a static block directly from a template PHP file (again, replace 'IDENTIFIER'):

...
Template text...
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId(IDENTIFIER)->toHtml() ?>
More template text under block...
...