tags:

views:

2214

answers:

6

I have this code in a xml layout file:

<reference name="left">     
      <block type="blog/blog" name="left.blog.menu"  before="-">            
    <action method="setTemplate" ifconfig="blog/menu/left">
       <template>aw_blog/menu.phtml</template> 
    </action>
        <block type="blog/tags" name="blog_tags" />
      </block>
</reference>

I want to add a cms static block to the blog pages using this code:

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

If I add it in directly after this line:

<reference name="left"> 

It works but it is then displayed on every page. How can I get it to show only on the blog pages?

Thanks.

Edit: Here is the entire xml file:

<layout version="0.1.0">
    <default>
        <reference name="footer_links">
            <block type="blog/blog" name="add.blog.footer">
                <block type="blog/tags" name="blog_tags" />
                <action method="addFooterLink" ifconfig="blog/menu/footer"></action>
            </block>
        </reference>
        <reference name="right">
            <block type="blog/blog" name="right.blog.menu" before="-">
                <action method="setTemplate" ifconfig="blog/menu/right" ifvalue="1">
                    <template>aw_blog/menu.phtml</template> 
                </action>
                <block type="blog/tags" name="blog_tags" />
            </block>
        </reference>
        <reference name="left">     
            <block type="blog/blog" name="left.blog.menu"  before="-">          
                <action method="setTemplate" ifconfig="blog/menu/left">
                    <template>aw_blog/menu.phtml</template> 
                </action>
                <block type="blog/tags" name="blog_tags" />
            </block>
        </reference>
        <reference name="top.links">
            <block type="blog/blog" name="add.blog.link">
                <action method="addTopLink" ifconfig="blog/menu/top"></action>
                <block type="blog/tags" name="blog_tags" />
            </block>
        </reference>
        <reference name="head">
            <action method="addItem"><type>skin_css</type><name>aw_blog/css/style.css</name></action>
        </reference>
    </default>

    <blog_index_index>
        <reference name="content">
            <block type="blog/blog" name="blog" template="aw_blog/blog.phtml"/>
        </reference>
    </blog_index_index>

    <blog_index_list>
        <reference name="content">
            <block type="blog/blog" name="blog" template="aw_blog/blog.phtml"/>
        </reference>
    </blog_index_list>  
    <blog_post_view>
        <reference name="content">
            <block type="blog/post" name="post" template="aw_blog/post.phtml">
                <block type="socialbookmarking/bookmarks" name="bookmarks" template="bookmarks/bookmarks.phtml"/>
            </block>
        </reference>
    </blog_post_view>
    <blog_cat_view>
        <reference name="content">
            <block type="blog/cat" name="cat" template="aw_blog/cat.phtml" />
        </reference>
    </blog_cat_view>

    <blog_rss_index>
        <block type="blog/rss" output="toHtml" name="rss.blog.new"/>
    </blog_rss_index>
</layout> 
A: 

if it's going inside a section then it will be applied to all pages, you want to put the and its contents inside the sections (there'll be the listing page and individual post pages - the sections should already exist in the aw_blog.xml file

Greg
A: 

Nice technique/ I'm going to apply this in my web development projects.

Magento Developer
A: 

Magento Developer

Magento Developer
A: 

It appears on all pages, because you probably put the code in the section of the layout xml. Just put into a section named after the route where it should appear. So try:

<blog>
    <reference name="left">
        <block type="cms/block" name="brand_list">
            <action method="setBlockId"><block_id>brand_list</block_id></action>
        </block>
    </reference>
</blog>
Marc Jakubowski
A: 

Nice post

i m new to Magento and what i want to do is i have three category and created and setup three static block for all categories in the middle of page now i want to move it to right sidebar pls. suggest how to set it up in right side above the Shopping Cart block and it should be for specific category only ( example : On Category 1 it's only display static block "bloc_1" which created for it same with other categories ) any help is appreciated and Thanks in Advance :)

yogs
A: 

Change XML inside folder theme/layout for example page.xml add something like this to header:

  <block type="page/html_header" name="header" as="header">
        <!-- ... some origin code ... -->
        <block type="page/html" name="custom_block" as="flashHeader" template="customer/custom_header.phtml"/>
  </block>

Create file customer/custom_header.phtml with your custom html code.

Inside template page/html/header.phtml you can add something like this:

$dataCurrentPage = $this->getHelper('cms/page')->getPage()->getData();
$page_id = (isset($dataCurrentPage['identifier'])) ?  $dataCurrentPage['identifier'] : null;
if ($page_id  == 'home' ) { echo this->getChildHtml('flashHeader') }

Flash banner will be show only on homepage.

OzzyCzech