2016-12-16 73 views
0

我想知道如何找到某个页面的块类型示例:主页。获取页面的块类型Magento

我在我的网页有问题,我想展示一些块,在XML中,我宣布我的块<cms_index_index>(local.xml中),但如果我把它放在它出现在<reference name="head">,如果<reference name="content"><reference name="content">它不行 。在我看来,块的类型不好。

XML:

<cms_index_index> 
     <reference name="root"> 
      <block type="core/template" name="seconnecter_test" template="customer/form/test-seconnecter.phtml"/> 
     </reference> 
</cms_index_index> 
在网页1column-full.phtml我把它叫做这样

<?php echo $this->getChildHtml('seconnecter_test');?> 
+0

解决方案:$ this-> getBlockHtml('name_block'); – Prince

回答

0

您可以使用

<reference name="root"> 
    <block type="core/template" name="seconnecter_test" output="toHtml" template="customer/form/test-seconnecter.phtml"/> 
</reference> 
+0

使用output =“toHtml”将块作为输出块,只有输出块自动呈现。 –

+0

我测试了它的工作原理,但它显示了页面底部的区块,而我想在一些区块之后在中间显示它,这就是为什么我想使用参考名称=“root”和get phtml中的get子项。 – Prince

+0

您可以在块定义中使用before/after属性。 –

0

当你给<reference name="content">他们的块类型是core/text_list。此块类型自动输出其内容,您不需要使用getchildhtml()

在你local.xml中

<?xml version="1.0"?> 
<layout version="0.1.0"> 
    <cms_index_index> 
    <reference name="content"> 
     <block type="core/template" name="seconnecter_test" before="_" template="customer/form/test-seconnecter.phtml"/> 
    </reference> 
    </cms_index_index> 
</layout> 

发生在正确的位置的模板文件,块将呈现在内容的顶部。

或者试试这个从管理面板去cms->pages->homepage。在布局更新xml中添加以下设计部分

<reference name="content"> 
     <block type="core/template" name="seconnecter_test" before="_" template="customer/form/test-seconnecter.phtml"/> 
    </reference> 

刷新缓存。

+0

我测试过了,它不起作用!我使用了Suman Singh的解决方案,但是它显示了底部的块,而我想在一些块之后在中间显示它,这就是为什么我想使用参考名称=“root”和phtml中的get子项的原因。 – Prince

+0

你可以把getchildhtml()调用到你想要的地方。 – Shrikant

+0

是的,但你的解决方案不显示任何东西,我使用了getChildHtml的output =“toHtml”它的作品,但它显示了页脚下的块,我不想要这个,我想在getChildHtml的位置显示它。 – Prince