将 Plone 联系表工作到 main_template.pt 中
我正在尝试使用已烘焙到我网站的 main_template 中的联系表单。我这样做是为了使此网站上的“联系”导航按钮中存在的功能在克隆中工作环境。我的方法是稍微修改 contact-info.cpt 使其成为宏并在 main_template 中使用该宏.pt。当我尝试查看网站上的任何页面时,我会收到 LocationError 错误,除非我从 contact-info.cpt 中删除 tal:define="errors options/state/getErrors"
行。
This 是我在代码中该行遇到的错误。如果我删除该行,页面将呈现并且实际上看起来完全符合我想要的方式,但在提交表单时会出错。 这就是这种情况下的错误。我基本上对这两种情况都感到困惑,并希望得到任何建议。
更新(我使用的解决方案):
只是想发布一个更新,说明我实际上是如何让它工作的。 Martijn Pieters 提供的信息对于理解为什么它不起作用非常有帮助,但我确实无法从那里开始工作。我最终依靠 jQuery 让它在 site_actions 和我的自定义下拉列表中工作。我用一个 div 将表单的内容包裹在
标签之间,我给了简单的 id“contact-info”。然后在主模板中,我还输入了一个通用 div,其简单 id 为“load-area”。最后一个难题是将我的 contact.js 文件更改为 contact.js.pt 并输入以下 3 行:
<tal:block define="portal_url context/@@plone_portal_state/portal_url">
jq('#load-area').load('<span tal:replace="portal_url"></span>/contact-info #contact-info');
</tal:block>
我想我应该发布此内容,以防它以后可以帮助其他人。
I'm trying to work the contact form that is baked into plone into my site's main_template. I'm doing so to make the functionality present in "get in touch" nav button on this site work in a plone setting. My approach to doing this was by slightly reworking contact-info.cpt to make it a macro and using that macro within main_template.pt. I get a LocationError when I try to view any page on my site, unless i remove the tal:define="errors options/state/getErrors"
line from contact-info.cpt.
This is the error I get with that line in the code. If I remove that line the page will render and actually looks exactly the way I want it to, but will error out upon submitting the form. This is the error in that situation. I'm basically stumped in both situations and would appreciate any advice.
UPDATE (the solution I used):
Just wanted to post an update with how I actually got this to work. The information from Martijn Pieters was very helpful in understanding why it wasn't working, but I really wasn't in the position to getting working from there. I ended up falling back on jQuery to get this working in the site_actions and in my custom dropdown. I wrapped the contents of the form between the <metal:main>
tags with a div that i gave the simple id "contact-info". Then in the main template, I also entered a generic div with a simple id of "load-area". The last piece of the puzzle was to change my contact.js file to be contact.js.pt and enter these 3 lines:
<tal:block define="portal_url context/@@plone_portal_state/portal_url">
jq('#load-area').load('<span tal:replace="portal_url"></span>/contact-info #contact-info');
</tal:block>
Thought I should post this incase it can help anyone else out later.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您不能将控制器页面模板 (
.cpt
) 用作未更改的宏。首先,控制器 Python 脚本需要其“环境”中的一些参数(
options/state
结构就是其中之一),而在重新使用它的 TAL 语句时,您没有这些参数。您必须重新设计模板才能不依赖这些部分。其次,这是一个 HTML 表单,表单需要一个目标来将其数据发送到。在控制器页面模板中,这是由
.metadata
文件控制的,您必须显式设置它的目标。You cannot use a Controller Page Template (
.cpt
) as a macro, unchanged.First of all, a Controller Python Script expects a few parameters in it's "environment" (the
options/state
structure is one of these) that you don't have present when re-using it's TAL statements. You'll have to rework the template to not rely on those parts.Secondly, this is a HTML form, and a form requires a target to send it's data to. In a Controller Page Template this is controlled with the
.metadata
file, you'll have to set it's target explicitly.尝试
http://svn.quintagroup.com/products/quintagroup.portlet.pfg /trunk/
似乎不受支持,但
与 PloneFormGen 结合您可以创建一个联系表单并将其显示为 portlet
try
http://svn.quintagroup.com/products/quintagroup.portlet.pfg/trunk/
seems not to be supported though
in combination with PloneFormGen you can create a contact-form and show it as a portlet