0

我想在我网站的每个页面内容的顶部显示一个轮播和两个横幅。我从 page.xml 中的页脚块开始创建了一个自定义引用。所以这就是它的样子:

<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>

然后我在其中创建了一个 topcontent.phtml 文件

<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>

我的轮播显示正确,但是当我尝试在 topcontentLeft 或 topcontentRight 中放置一个块时,它不会全部显示。我想我在块类型参数上做错了,但我不知道是什么:有人可以帮我吗?谢谢。

4

2 回答 2

1

取决于您需要在横幅中显示的内容。如果只是一些文本,您可以使用文本块:

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

如果您需要占位符块来显示一些 CMS 静态块内容,那么您是对的,cote/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' id 在管理后端创建新的静态块,它会在您输出它的地方呈现。

于 2011-01-13T16:59:38.593 回答
0

我认为问题出在 topcontentLeft 和 topcontentRight 的 @type 属性中

type="core/text_list"  need to be changed to type="core/template"
于 2011-01-13T16:21:41.643 回答