如何在 magento 中添加 post var 作为模板标签的参数?

发布于 2025-01-06 02:14:25 字数 744 浏览 1 评论 0原文

在模板 account_new_confirmation 中,这是用户创建新帐户后收到的确认邮件的模板,我需要在标签内添加一个参数,

{{store url="customer/account/confirm/" _query_id=$customer.id _query_key=$customer.confirmation _query_back_url=$back_url _query_myparam="TEST"}}

该参数适用于生成以下链接的字符串,该链接将写入确认邮件中:预期:

http://baseurl/customer/account/confirm/?id=12345&key=donkey&back_url=monkey&myparam=TEST

但我不知道如何用请求帖子中的参数值替换字符串 TEST。
我的意思是用户在填写通过 POST 操作发送的表单后到达这一点。在此表单中,我有一个名为 FOO 的复选框,我需要将其值(true 或 false)添加到上面示例中的 _query_myparam。
我尝试过使用

_query_param=$foo

和使用

_query_param=$this->getRequest()->getPost('foo')

,但它们都太容易工作了。
有人知道如何解决这个问题吗?

Inside the template account_new_confirmation, which is the template of the confirmation mail the user receives after he creates a new account, I need to add a param inside the tag

{{store url="customer/account/confirm/" _query_id=$customer.id _query_key=$customer.confirmation _query_back_url=$back_url _query_myparam="TEST"}}

this is working for a string producing the following link to be written inside the confirmation mail as expected:

http://baseurl/customer/account/confirm/?id=12345&key=donkey&back_url=monkey&myparam=TEST

but I cannot figure out how to replace the string TEST with the value of a param I have in request post.
I mean the user reach this point after having filled a form sent with POST action. Inside this form I have a checkbox named FOO and I need to add its value (true or false) to _query_myparam on my example above.
I tried with

_query_param=$foo

and with

_query_param=$this->getRequest()->getPost('foo')

but they both were too easy to work.
Anyone knows how to solve this?

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

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

发布评论

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

评论(1

只是一片海 2025-01-13 02:14:25

我自己发现了它:D

您必须更改类Mage_Customer_Model_Customer的方法sendNewAccountEmail,您可以在app/code/core/Mage/中找到它Customer/Model/Customer.php

您需要在模板内添加可用的新变量:

array('customer' => $this, 'back_url' => $backUrl)

因此,根据您的需要,这将被更改为:

array('customer' => $this, 'back_url' => $backUrl, 'foo' => Mage::app()->getRequest()->getPost('foo'))

然后您可以将此变量添加到模板参数中,因为

{{store url="customer/account/confirm/" _query_id=$customer.id _query_key=$customer.confirmation _query_back_url=$back_url _query_myparam=$foo}}

这将产生以下链接:

http://baseurl/customer/account/confirm/?id=12345&key=donkey&back_url=monkey&myparam=on

当选中复选框 FOO 时。

谢谢

I found it myself :D

You have to change the method sendNewAccountEmail of the class Mage_Customer_Model_Customer which you can find in app/code/core/Mage/Customer/Model/Customer.php

You need to add new variables available inside the template inside:

array('customer' => $this, 'back_url' => $backUrl)

So for your need this would be changed in:

array('customer' => $this, 'back_url' => $backUrl, 'foo' => Mage::app()->getRequest()->getPost('foo'))

Then you can add this variable to the template param as

{{store url="customer/account/confirm/" _query_id=$customer.id _query_key=$customer.confirmation _query_back_url=$back_url _query_myparam=$foo}}

This will produce the following link:

http://baseurl/customer/account/confirm/?id=12345&key=donkey&back_url=monkey&myparam=on

when checkbox FOO is checked.

Thanks

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