Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding a new reference block to Magento

I'm having some trouble getting a custom Reference block to work in Magento.

These are the steps I have taken:

Step 1

Created a new “Reference” block in page.xml

<block type="core/text_list" name="newreference" as="newreference"></block>

Step 2

Added a reference to this block in the place I want it to appear in the page (above the footer in 1column.phtml, 2columns-left.phtml, 2columns-right.phtml, 3columns.phtml)

<?php $this->getChildHtml('newreference'); ?>

Step 3

Added a reference to catalog.xml which tells Magento I want to output a template part (specialfooter.phtml) in the ‘newreference’ Reference block on Category pages

<reference name="newreference">
     <block type="core/template" name="specialfooter" template="page/html/specialfooter.phtml"></block>
</reference>

Step 4

Created ‘specialfooter.phtml’ in the page/html/ directory with a simple paragraph block to test.

And nothing happens.

The steps I have taken fit with my understanding of how Reference blocks work, but I could be wrong. I'm struggling to find any documentation, official or otherwise, or any previous SO questions which sheds any light on the subject.

I'm using Magento ver. 1.7.0.2.

Any help would be much appreciated.

like image 742
john0514 Avatar asked Oct 24 '12 06:10

john0514


People also ask

How do I create a reference block in Magento 2?

By using Magento/Cms/Block/Block class with “block_id” arguments, a CMS block can be placed in the layout. Take an example: Create a static block and add it to the top of the page footer. Step 1: Create a static block as footer_top in the admin. Step 3: Clear cache and check the results.

How do you add a block in XML?

Click Add Content > Default > Block. Select XML and click Choose. In the Name field, enter a name for your block. In the Placement Folder field, choose the folder where the block should be created.

What is reference block in Magento 2?

ReferenceBlock: ReferenceBlock is used when we want to use already existing block and want to put our block in that existing block. We use this if we want to add changes to phtml file of that block.


1 Answers

Don't you have forget a echo ? :

<?php echo $this->getChildHtml('newreference'); ?>
like image 143
Jscti Avatar answered Sep 21 '22 16:09

Jscti