2011-01-13 33 views
0

我想在網站的每個頁面內容的頂部顯示一個輪播和兩個橫幅。 我已經創建了一個自page.xml中的頁腳塊開始的自定義引用。 因此,這是什麼樣子:爲Magento佈局中的靜態塊提供新參考

<block type="page/html" name="topcontent" as="topcontent" template="page/html/topcontent.phtml"> 
    <block type="page/html_wrapper" name="topcontent.container" as="topcontentContainer" translate="label"> 
     <label>Page Top Content</label> 
     <action method="setElementClass"><value>topcontent-container</value></action> 
    </block> 
    <block type="core/template" name="topcontent.book.carousel" as="topcontentCarousel" template="callouts/book-carousel.phtml"/> 
    <block type="core/text_list" name="topcontent.left" as="topcontentLeft" /> 
    <block type="core/text_list" name="topcontent.right" as="topcontentRight" /> 
</block> 

然後,我創建了這裏我把

<div class="topcontent-container"> 
    <div class="topcontent"> 
     <?php echo $this->getChildHtml('topcontentContainer') ?> 
     <?php echo $this->getChildHtml('topcontentCarousel') ?> 
     <?php echo $this->getChildHtml('topcontentLeft') ?> 
     <?php echo $this->getChildHtml('topcontentRight') ?> 
    </div> 
</div> 

我已經正確地顯示我的傳送帶用topcontent.phtml文件,但是當我試圖把塊topcontentLeft或topcontentRight,它不會全部顯示。 我想我做的塊類型參數錯了,但我不明白什麼:有人可以給我一些幫助嗎? 謝謝。

回答

1

取決於你需要的橫幅顯示的內容。如果它只是一些文字,你可以使用文本塊:

<block type="core/text" name="topcontent.right" as="topcontentRight"> 
    <action method="addText"><text>Test text</text></action> 
</block> 

如果需要佔位符塊表現出一定的CMS靜態塊的內容,那麼你是對的,科特/ text_list是這樣的塊合適的類型。它將所有它的嵌套塊並逐一渲染。所以接下來你需要做的就是放置cms/block佔位符,它的內容可以稍後從後端添加。總之它可能看起來像:

<block type="core/text_list" name="topcontent.right" as="topcontentRight"> 
    <block type="cms/block" name="topcontent.right.cms" as="topcontentRightCms"> 
     <action method="setBlockId"><block_id>topcontent_right_static</block_id></action> 
    </block> 
</block> 

現在,你可以在「topcontent_right_static」身份證管理後臺創建新的靜態集團,它會在適當的位置呈現在您輸出。

0

我認爲這個問題是在topcontentLeft的@type屬性和topcontentRight

type="core/text_list" need to be changed to type="core/template" 
+0

我已經試過了,但沒有解決問題。我認爲核心/模板需要一個.phtml模板才能工作。 – pasine 2011-01-13 16:35:39

+0

是的,它應該與模板 – 2011-01-13 16:40:01