0

i am a Magento Newbie.

In the local.xml under the header section these blocks are defined:

<reference name="header">
    <block type="cms/block" name="flatshop_header_support">
        <action method="setBlockId"><block_id>flatshop_header_support</block_id></action>
    </block>
    <block type="cms/block" name="flatshop_header_2blocks">
        <action method="setBlockId"><block_id>flatshop_header_2blocks</block_id></action>
    </block>

in the header.phml both are called like:

<?php echo $this->getChildHtml('flatshop_header_support') ?>
<?php echo $this->getChildHtml('flatshop_header_2blocks') ?>

On /admin/cms_block/ static block with "flatshop_header_support" Identifier are defined and filled with content like "flatshop_header_2blocks" (this is working well), but the return is string(0) ""

How can i print flatshop_header_support block in the header section?

Magento v1.9.1 template: Flathop

eapo
  • 1,053
  • 1
  • 19
  • 40

1 Answers1

2

I can suggest you 3 different ways to solve your issue here.

I would strongly suggest my number (3), it is the best way and would not recommend number (2).

1) just use the below code in your header.phtml file instead of what you have used to call the static blocks in your phtml file

    <?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('flatshop_header_support')->toHtml(); ?>
    <?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('flatshop_header_2blocks')->toHtml(); ?>

2) Instead of local.xml, use your "reference block" codes from local.xml and paste it in page.xml inside

    <block type="page/html_header" name="header" as="header">---</block>

it should work as well

3) The script that you are using has no problem, the only thing I could say is, your local.xml is not setup correctly which is why it is not executed, look for simple details like xml tags or compare with the code that I am using for local.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <layout version="0.1.0">
      <default>
          <reference name="header">
             <block type="cms/block" name="flatshop_header_support">
                <action method="setBlockId"><block_id>flatshop_header_support</block_id></action>
            </block>
            <block type="cms/block" name="flatshop_header_2blocks">
                <action method="setBlockId"><block_id>flatshop_header_2blocks</block_id></action>
            </block>
           </reference>
      </default>
    </layout> 

Hope my answer solves your issue.

Pradino
  • 462
  • 1
  • 5
  • 19
  • The 1), 2) version are working well. in case of 3) only the `encoding="UTF-8"` was missing. thank You! – eapo Jul 16 '14 at 19:40