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

Adding new block in local.xml
 
SaphireFalcon
Jr. Member
 
Total Posts:  3
Joined:  2011-02-22
 

I’m trying to add a block to the header in local.xml with the code:

<reference name="header">
    <
block type="core/template" name="myheader" template="page/html/myheader.phtml" />
</
reference>

With in page/html/myheader.phtml:

<div class="myheader">
    
BOE!!!
</
div>

Unfortunately this doesn’t work.
Also searching on the forum and web only gave me the hint to copy the file page.xml to the layout folder, which I did. But that didn’t help.

 
Magento Community Magento Community
Magento Community
Magento Community
 
MagePsycho
Mentor
 
Avatar
Total Posts:  1702
Joined:  2009-06-23
 

Can you post the full XML code of local.xml?

 
Magento Community Magento Community
Magento Community
Magento Community
 
SaphireFalcon
Jr. Member
 
Total Posts:  3
Joined:  2011-02-22
 

Here is the whole code for the local.mxl:

<?xml version="1.0" encoding="UTF-8"?>
<layout version="0.1.0">
    <default>
        <!-- 
Change the default template of all pages -->
        <
reference name="root">
            <
action method="setTemplate">
                <
template>page/2columns-right.phtml</template>
            </
action>
        </
reference>
        
        <!-- 
Remove callouts and rarely used stuff -->
        <
remove name="right.poll"/>
        <
remove name="right.permanent.callout"/>
        <
remove name="paypal.partner.right.logo" />
        <
remove name="left.permanent.callout"/>
        <
remove name="top.search" />
        
        <!-- 
add the local stylesheet -->
        <
reference name="head">
            <
action method="addCss">
                <
stylesheet>css/local.css</stylesheet>
            </
action>
        </
reference>
        
        <!-- 
add a block to the header -->
        <
reference name="header">
            <
block type="core/template" name="myheader" template="page/html/myheader.phtml" />
        </
reference>

    </default>
</
layout>
 
Magento Community Magento Community
Magento Community
Magento Community
 
SaphireFalcon
Jr. Member
 
Total Posts:  3
Joined:  2011-02-22
 

After some killing path trials I found out that my folder ‘template’ was called ‘templates’. downer
Now everything works…

 
Magento Community Magento Community
Magento Community
Magento Community
 
Ed_Rolla
Jr. Member
 
Avatar
Total Posts:  6
Joined:  2012-01-26
Rio de Janeiro
 

Hi,
I have a similar doubt.

Suppose I create a static block by the backend interface (cms -> static blocks) and set it’s ID to “static_block_test”.

I added it in the content of the homepage (CMS -> pages -> homepage -> content) and it worked beautifully, it looks something like this:

{{widget type="cms/widget_block" template="cms/widget/static_block/default.phtml" block_id="4"}}

But, suppose I wish to add it to the header instead. So I should use XML on the Design tab instead, right? But the thing is that I’m having an incredible hard time learning the Magento’s XML syntax. Can someone help me out? I know it should go something like this so far…

<reference name="header">
    <
block type="cms/block"  name="static_block_test">
        <
action method="setBlockId">
            <
block_id>4</block_id>
        </
action>
    </
block
</
reference>

Any ideas?  downer
cheers!

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