1

I have a custom template block (phtml) that is defined like this:

<block type="catalog/product" name="a.unique.name" template="dir/dir/customlist.phtml"/>

that is defined in CMS home page within this block

<reference name="left">

However if I move it to header block, it does not appear

<reference name="header">

What am I missing here?

** ---- addition -----

I tried this as suggested by D. Sloof, but it does not work. (I suspect more due to my mis-actions than his explanation.)

I added getChildHtml('customlist'); ?> to

mytheme\template\page\html\header.phtml  

just under div "top-col-1"

   <div class="wrapper">
     <div class="top-col-1">        
        <?php echo $this->getChildHtml('customlist'); ?> 

where "customlist" can befound in

mytheme/template/dir/dir/customlist.phtml

What am I doing wrong?

4

2 に答える 2

1

とった...

xml ファイル内のブロック名a.unique.name

<block type="catalog/product" name="a.unique.name" template="dir/dir/customlist.phtml"/>

mytheme\template\page\html\header.phtml で呼び出されるものと一致する必要があります

<?php echo $this->getChildHtml('a.unique.name'); ?> 
于 2012-09-20T21:49:06.273 に答える
0

headerブロックは型であり、Mage_Page_Block_Html_Header子ブロックを自動的にレンダリングしません。page/html/header.phtml子ブロックの html がどのように取得されるかは、テンプレート ファイルで確認できます。

基本的に 2 つのオプションがあります。

  • ヘッダー テンプレートに独自の呼び出しを追加するgetChildHtml(独自のテーマにコピーすることにより)、または;
  • 子ブロックを自動的にレンダリングするコンテナー内にブロックを配置します。leftブロックはこれを行うタイプですMage_Core_Block_Text_Listheaderと呼ばれるブロック内に、これを行うtop.containerタイプの同様のブロックがあります。代わりに、このブロックを参照できます。Mage_Page_Block_Html_Header
于 2012-09-20T19:06:28.220 に答える