Magento Block无法使用参考

时间:2012-09-06 19:08:11

标签: magento module block

我正在为前端创建一个新的Magento 1.7.0.2模块,但我无法将我的一个块连接到页面的任何正常位置。目前,它隐藏在页面底部,所有默认内容都在其上方。我还没有真正搞好前端,所以这是一个相当新鲜的Magento安装。我已经尝试了参考标记,但是如果我将它们包括在内,那么无论我在名称引号中添加什么,我的块都会完全消失。

我的布局:

<?xml version="1.0"?>

<layout version="0.1.0">
    <default>
    </default>
    <!--<reference name="root">-->
        <makeorder_index_index>
            <block type="makeorder/testblock" output="toHtml" name="orderdispaly"
                    template="makeorder/orderdisplay.phtml"/>
        </makeorder_index_index>
    <!--</reference>-->
</layout>

我目前的模板:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Test Block</title>
</head>
<body>
    <h2>Hello!</h2>
    <div class="Test1">
        <?php echo $this->displaystyles();?>
    </div>
    <br /><hr /><br />
    <div class="test2">
        <?php echo $this->displaypapers();?>
    </div>

</body>
</html> 

我想将块放到页面中间。任何帮助将不胜感激,因为我显然缺少一些重要的东西。

1 个答案:

答案 0 :(得分:0)

你的布局xml中有几个错误,但不是纠正它们,我会以这种方式作为开始(除非你有理由想在你自己的模板中重新创建整个页面布局?)

<强>布局:

<?xml version="1.0"?>

<layout version="0.1.0">
    <makeorder_index_index>
        <reference name="root">
            <action method="setTemplate"><template>page/1column.phtml</template></action>
        </reference>
        <reference name="content">
            <block type="makeorder/testblock" name="orderdispaly" template="makeorder/orderdisplay.phtml" />
        </reference>
    </makeorder_index_index>
</layout>

<强>模板:

<h2>Hello!</h2>
<div class="Test1">
    <?php echo $this->displaystyles();?>
</div>
<br /><hr /><br />
<div class="test2">
    <?php echo $this->displaypapers();?>
</div>