I created a new template file, where I placed some custom code, that I want to load inside a page.
I created a CMS page where I load the template file by using:
{{block type="core/template" template="/aw_blog/share.phtml"}}
I need to use the same php code as the default template file, so I need to define the template by: <?php $post = $this->getPost();?>
The default template file is defined inside the XML file like:
 <reference name="content">
 <block type="blog/post" name="post" template="aw_blog/post.phtml">
 <block type="blog/product_toolbar" name="aw_blog_list_toolbar" template="aw_blog/toolbar.phtml">
 <block type="blog/html_pager" name="product_list_toolbar_pager"/>
 </block>
 </block>
 </reference>
So I edit the XMl file:
 <reference name="content">
 <block type="blog/post" name="post" template="aw_blog/post.phtml">
 <block type="blog/product_toolbar" name="aw_blog_list_toolbar" template="aw_blog/toolbar.phtml">
 <block type="blog/html_pager" name="product_list_toolbar_pager"/>
 </block>
 </block>
 <block type="blog/post" name="post" template="aw_blog/share.phtml">
 <block type="blog/product_toolbar" name="aw_blog_list_toolbar" template="aw_blog/toolbar.phtml">
 <block type="blog/html_pager" name="product_list_toolbar_pager"/>
 </block>
 </block>
 </reference>
But that does not work, because that breaks down the page. It does not load the default content anymore.
What am I missing?
1 Answer 1
Try to use same block type in directive. Instead:
{{block type="core/template" template="/aw_blog/share.phtml"}}
use:
{{block type="blog/post" template="/aw_blog/share.phtml"}}
If you need to customize block behavior, then make a custom module with a block extending from blog one and use it in layout and template.
You will have to add the block type to the block whitelist that has been introduced in Magento 1.9.2.2 (and with a security patch for older versions), otherwise it will not be displayed. See APPSEC-1057 How to add variables or blocks to the white list tables
- 
 Thanks! I tried that, but in that case the total block is not displayed inside the page.JGeer– JGeer2016年02月18日 08:23:45 +00:00Commented Feb 18, 2016 at 8:23
- 
 Is the first slash needed ? Never seen that before, it's usually justaw_blog/share.phtmlRaphael at Digital Pianism– Raphael at Digital Pianism2016年02月18日 09:41:02 +00:00Commented Feb 18, 2016 at 9:41
- 
 The slash is unnecessary but should not do harm. The problem is block whitelisting, see updated answer.Fabian Schmengler– Fabian Schmengler2016年02月19日 09:46:25 +00:00Commented Feb 19, 2016 at 9:46