【问题标题】:Calling right block in Magento 1.6.2 of static html在静态 html 的 Magento 1.6.2 中调用右块
【发布时间】:2012-06-23 03:35:54
【问题描述】:

我正在 magento 中创建一个 CMS 页面,作为即将推出的产品的预告片。我正在使用带有右栏的两列,并在后端使用布局更新 XML 来调用我为右侧制作的一些自定义块。

现在我只加载占位符,然后在事后编辑 phtml。

如果我在右侧使用两个块,它看起来很好。但如果我添加更多,那么整个页脚会损坏并移动到右列。​​

我正在尝试在右侧获取 3 个自定义块。

这是我的布局更新 XML

<reference name="right">
<block type="newsletter/subscribe" name="left.newsletter" template="newsletter/rightsubscribe.phtml"/>
<block type="core/template" name="name1" template="page/custom/custom1.phtml"/>
<block type="core/template" name="name2" template="page/custom/custom2.phtml"/>
</reference>

这是我正在使用的海关区块的 HTML。

<div id="shop-with-confidence" class="white-box">
    <h3>Custom1</h3>
    <div class="white-box-inner">
         Testing1
    </div>


    <div id="shop-with-confidence" class="white-box">
    <h3>Custom2</h3>
    <div class="white-box-inner">
         Testing2
    </div>

有人知道为什么这会破坏我正在编辑的页面吗?

【问题讨论】:

  • 由于我是新手,还不能在这里回答我自己的问题!
  • 伙计,这很糟糕。经过大约 4 小时的故障排除和阅读许多 magento XML 文档的方法后,它只是缺少每个文件的结束 div。我最初认为我不能使用两种相同的核心/模板类型的块类型,并且很明显地阅读了很多内容。 div 监督 FTL。
  • 是的,这将是我的建议,因为这是唯一可能的选择。

标签: html magento static-block


【解决方案1】:

OP 已经自己解决了这个问题,但值得注意的是,人们可以轻松检查父子块关系以确定问题是框架相关还是标记相关。

要检查父块具有的子块列表,只需在模板中执行以下操作:

Zend_Debug::dump($this->getChild()) //list of children
Zend_Debug::dump($this->getSortedChildren()) //list of ordered children

如果块缺少模板(core/text_list,例如“正确”),也可以从子块模板中执行此操作:

Zend_Debug::dump($this->getParentBlock()->getChild()) //list of children
Zend_Debug::dump($this->getParentBlock()->getSortedChildren()) //list of ordered children

请参考Mage_Core_Block_Abstract 了解更多信息。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多