一个新的块我昨天Static block on home page in Magento问过这个问题,它回答了一个挂钩CMS /块,以现有的块(内容,在例子)我的问题。建立在Magento
但现在我想知道如何创建自己的块。
我有这个在我的一个.phtml模板:
<?php echo $this->getChildHtml('home_flash') ?>
这在我cms.xml文件
<reference name="home_flash">
<block type="cms/block" name="home-page-flash" before="content">
<action method="setBlockId"><block_id>home-page-flash</block_id></action>
</block>
</reference>
但是,这是行不通的。
我也试图创建自己的块类型,(通过复制面包屑声明)在page.xml文件:
<block type="page/html_home_block" name="home_block" as="home_block" template="page/template/home_block.phtml"/>
该文件存在,但不被渲染。
然而,当我引用了块这样的:
<block type="page/html_breadcrumbs" name="home_block" as="home_block" template="page/template/home_block.phtml"/>
它使得我的家乡块模板,但原来的CMS /块不重视它。
希望所有的不同的情况表明正在发生的事情,并强调在我的知识缺口不够好,有人来回答,我必须某处“注册”我的新“home_block”型?
这并不是100%清楚你想要完成什么,这使得理解问题变得困难。你能解释一下你试图达到的最终结果是什么,以及更具体的事情吗? (即“我的.phtml模板”:哪个phtml模板?) – 2010-12-07 18:31:01
@Alan Storm,感谢评论,我知道这个问题很长,我试图在最后一行问题中总结它! @clockworkgeek回答了我的问题,事实证明我错过了关于Magento的MVC位的观点! – 2010-12-08 11:41:56