Magento - 如何将自定义块添加到结账成功页面

发布于 2024-10-09 02:02:42 字数 2654 浏览 1 评论 0原文

我想通过向页面添加一个块来向结帐成功页面添加一些信息(无需复制模板页面并进行更改)。

我查看了可下载模块并尝试复制它,但没有成功。 我有一个自定义模块,我尝试这样做:

1)添加一个块文件: ...\app\code\local\SHANI\MyModule\Block\checkout\Details.php

class SHANI_MyModule_Block_Checkout_Details extends Mage_Checkout_Block_Onepage_Success
{
}

2) 添加模板文件到: ...\app\design\frontend\default\default\template\mymodule\checkout\details.phtml

<?php
echo "test ffdagdf";
?>

3) 将块添加到: ...\app\design\frontend\default\default\layout\mymodule.xml

<default>
</default>

....
....
....

<checkout_onepage_success>
    <reference name="checkout.success">
        <block type="mymodule/checkout_success" name="mymodule.checkout.details" template="mymodule/checkout/details.phtml"/>
    </reference>
</checkout_onepage_success>

是否那是怎么做的呢?我缺少什么?

///////////////////////////////////////// 更新//////// /////////////////////////////////

我尝试像 Lrrr 写的那样更改 mymodule.xml 但仍然没有运气...

<checkout_onepage_success>
        <reference name="checkout.success">
            <block type="mymodule/checkout_details" name="mymodule.checkout.details" template="mymodule/checkout/details.phtml"/>
        </reference>
</checkout_onepage_success>

还有其他想法是什么问题吗?

我正在尝试对产品视图页面执行相同的操作,并且我能够向“product.info.additional”添加一个块 但不是“product.info”。

这是有效的:

<catalog_product_view>
        <reference name="product.info.additional">
           <block type="catalog/product_view" name="mymodule.saledetails" before="-" template="mymodule/product/details.phtml"/>
            <block type="mymodule/product_participant_list" name="mymodule.participants" before="-" template="mymodule/product/participant/list.phtml"/>
        </reference>
    </catalog_product_view>

但这不是

<catalog_product_view>
        <reference name="product.info">
                <block type="catalog/product_view" name="mymodule.saledetails" before="-" template="mymodule/product/details.phtml"/>
        </reference>
        <reference name="product.info.additional">
            <block type="mymodule/product_participant_list" name="mymodule.participants" before="-" template="mymodule/product/participant/list.phtml"/>
        </reference>
    </catalog_product_view>

我试图将这个块从“product.info.additional”移动到“product.info”,因为我想在下面显示这个块 快速概述(在默认模板中)而不是详细信息下。 为什么它在“product.info”下不起作用?

I want to add some information to the checkout success page by adding a block to the page (without duplicating the template page and changing it).

I've looked at the downloadable module and tried to copy it but that didn't work.
I have a custom module and I've tried to do this :

1) adding a block file to :
...\app\code\local\SHANI\MyModule\Block\checkout\Details.php

class SHANI_MyModule_Block_Checkout_Details extends Mage_Checkout_Block_Onepage_Success
{
}

2) adding a template file to :
...\app\design\frontend\default\default\template\mymodule\checkout\details.phtml

<?php
echo "test ffdagdf";
?>

3) adding the block to : ...\app\design\frontend\default\default\layout\mymodule.xml

<default>
</default>

....
....
....

<checkout_onepage_success>
    <reference name="checkout.success">
        <block type="mymodule/checkout_success" name="mymodule.checkout.details" template="mymodule/checkout/details.phtml"/>
    </reference>
</checkout_onepage_success>

Does that the way to do it? What am I missing?

///////////////////////////////////////// update/////////////////////////////////////////

I've tried to change the mymodule.xml like Lrrr wrote but still no luck...

<checkout_onepage_success>
        <reference name="checkout.success">
            <block type="mymodule/checkout_details" name="mymodule.checkout.details" template="mymodule/checkout/details.phtml"/>
        </reference>
</checkout_onepage_success>

any other ideas what is the problem?

I'm trying to do the same thing with the product view page and I was able to add a block to the "product.info.additional"
but not to the "product.info".

This is working:

<catalog_product_view>
        <reference name="product.info.additional">
           <block type="catalog/product_view" name="mymodule.saledetails" before="-" template="mymodule/product/details.phtml"/>
            <block type="mymodule/product_participant_list" name="mymodule.participants" before="-" template="mymodule/product/participant/list.phtml"/>
        </reference>
    </catalog_product_view>

But this isn't

<catalog_product_view>
        <reference name="product.info">
                <block type="catalog/product_view" name="mymodule.saledetails" before="-" template="mymodule/product/details.phtml"/>
        </reference>
        <reference name="product.info.additional">
            <block type="mymodule/product_participant_list" name="mymodule.participants" before="-" template="mymodule/product/participant/list.phtml"/>
        </reference>
    </catalog_product_view>

I'm trying to move this block from "product.info.additional" to "product.info" because I want to show this block under
the Quick Overview (in the default template) and not under the Details.
Why doesn't it work under the "product.info"?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

小苏打饼 2024-10-16 02:02:42

尝试在成功页面布局中引用内容块

<checkout_onepage_success>
    <reference name="content">
        <block type="mymodule/checkout_success" name="mymodule.checkout.details" template="mymodule/checkout/details.phtml"/>
    </reference>
</checkout_onepage_success>

而不是 checkout.success ,您可能需要在模板中调用 $this->getChildHtml('yourblockname') 或添加 output="toHtml " 到布局中的块

try to reference the content block in success page layout

<checkout_onepage_success>
    <reference name="content">
        <block type="mymodule/checkout_success" name="mymodule.checkout.details" template="mymodule/checkout/details.phtml"/>
    </reference>
</checkout_onepage_success>

instead checkout.success and you probably will need to call $this->getChildHtml('yourblockname') in template or add output="toHtml" to your block in layout

_畞蕅 2024-10-16 02:02:42

尝试

print $this->getChildHtml('mymodule.checkout.details')

在父模板中不使用 xml 中的 output="" 。

您还可以检查日志以获取其他信息。

为了确保现在是您的模块的错误,请将其替换为“

type="core/template"

如果您的模块是,

SHANI_MyModule_Block_Checkout_Details

则类型应该是”

type="mymodule/checkout_details"

Try

print $this->getChildHtml('mymodule.checkout.details')

inside parent template without output="" in xml.

You can also check log for aditional info.

And to be sure it's now fault of Your block replace it with

type="core/template"

If Your module is

SHANI_MyModule_Block_Checkout_Details

then type should be

type="mymodule/checkout_details"
猫九 2024-10-16 02:02:42

"core/template" name="child" template=" child" />

如果您将其放入parent.phtml print $this->getChildHtml('child') Magento 应该在parent.phtml中渲染child.phtml

至于您的其他问题...有些块渲染所有属于它们的子块,但有些块仅渲染在其模板内回显的那些块,因此“product.info.additional”。可以使用 echo $this->getChildHtml() 和 'product.info' 可以使用 echo $this->getChildHtml('block_name')

请向我提供您的模块配置文件

<block type="core/template" name="parent" template="parent.phtml>

<block type="core/template" name="child" template="child" />

</block>

If You put in parent.phtml this print $this->getChildHtml('child') Magento should render child.phtml inside parent.phtml

As for Your other question... Some block render all blocks that are childs to them, but some renders only those blocks that are echo'ed inside their template. So 'product.info.additional' can use echo $this->getChildHtml() and 'product.info' can use echo $this->getChildHtml('block_name')

Please provide me Your module config.xml

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文