Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Need the Noobs Guide to Inserting a Static Block. 
 
cathyka
Member
 
Total Posts:  62
Joined:  2008-04-03
 

I added a new CMS > Static Block

Title = My Block

Identifier = my_block

It includes basic html to create a menu of outgoing links.

<ul>
<li> <a href="http://outgoing.com">Link One</a></li>
<li> <a href="http://outgoing.com">Link Two</a></li>
<li> <a href="http://outgoing.com">Link Three</a></li>
</ul>

I want the menu to appear in the header (header.phtml?)
and appear on all pages.

I just can’t seem to get this to work. I have reviewed numerous previous posts, tried and nothing.
including http://www.magentocommerce.com/boards/viewthread/3977/

What files do I need to modify and how?
I know it is something simple, but I just can’t seem to get it. I afraid I need the idiots guide to static block insertion. Help a noob.

Thanks!

 
Magento Community Magento Community
Magento Community
Magento Community
 
FOOMAN
Guru
 
Avatar
Total Posts:  669
Joined:  2007-12-13
Auckland, New Zealand
 

Hi Cathyka,

I am assuming you are working on a custom theme. To add your CMS block to the header try the following:

In the file /app/design/frontend/default/YOURTHEMENAME/layout/page.xml

locate the block named “header”. It probably looks something similar to this.

<block type="page/html_header" name="header" as="header">
    <
block type="page/template_links" name="top.links" as="topLinks"/>
    <
block type="page/switch" name="store_language" as="store_language" template="page/switch/languages.phtml"/>
    <
block type="core/text_list" name="top.menu" as="topMenu"/>
</
block>

You then need to add your CMS block as a child to the above block like so:

<block type="page/html_header" name="header" as="header">
    <
block type="page/template_links" name="top.links" as="topLinks"/>
    <
block type="page/switch" name="store_language" as="store_language" template="page/switch/languages.phtml"/>
    <
block type="core/text_list" name="top.menu" as="topMenu"/>

    <
block type="cms/block" name="my_block">
        <
action method="setBlockId"><block_id>my_block</block_id></action>
    </
block>
</
block>

The block should now already appear on the page. If not or to customise how it appears go to the file
/app/design/frontend/default/YOURTHEMENAME/template/page/html/header.phtml

and call the block with the following code where you see fit:

<?php echo $this->getChildHtml('my_block'?>
 
Magento Community Magento Community
Magento Community
Magento Community
 
cathyka
Member
 
Total Posts:  62
Joined:  2008-04-03
 

Thanks so much. I have no idea what I missed the multiple times I tried yesterday, but this worked like a charm.
Thanks!

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top