如何在 PyroCMS 上自动创建小部件?

发布于 2024-10-08 19:45:18 字数 399 浏览 1 评论 0原文

我想开发一个模块作为带有注册表单的活动。事件实际上是一个页面模块,稍微修改一下,添加一些字段,例如注册表单网址。当控制器返回视图时,我希望控制器返回注册表单小部件以及事件信息(文章)和谷歌地图小部件。

想象一个小部件类:

<?php
    class Registration_Form_Widget extends Widget{
       ......
   }

我的问题是: 是否可以动态创建小部件(我的意思是小部件实例的创建是动态的(而不是内容),例如使用新的 Registration_Form_Widget 并绕过参数,例如已存储到数据库的注册表单网址?

到目前为止,我从未见过示例展示了如何使用自动增量 ID 动态创建小部件实例,

谢谢...

I'd like to develop a module as an event with registration form. An event is actually a page module with slight modification by adding some fields such registration form url. When the controller return a view, I'd like the controller to return a registration form widget along with the event info (article) and a google maps widget.

Imagine a widget class:

<?php
    class Registration_Form_Widget extends Widget{
       ......
   }

My question is:
Is it possible to create widget dynamically (I mean the creation of widget instance is dynamic (not the content) such using new Registration_Form_Widget and bypass the parameter such the registration form url that has been stored to the database?

So far, I never see an example that show how to create widget instance dynamically with automatic increment id

thanks...

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

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

发布评论

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

评论(2

蓝眼睛不忧郁 2024-10-15 19:45:18

不,只要您创建小部件,就会创建它们。

Nope, widgets are created whenever you create em.

一人独醉 2024-10-15 19:45:18

尽管显然可以通过一些代码来实现它。
没有“神奇功能”可以自动执行此操作,但您可以查看小部件模块文件以了解当用户在管理 CP 中创建小部件时会执行哪些操作。然后你可以自己重现该行为。

Although it is obviously possible to achieve it with a bit of code.
There is no "magic function" to do that automatically, but you can look into the widget module files to understand what is done when a user create a widget in the admin CP. And then you could reproduce the behaviour yourself.

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