从其他插件的主体调用 TYPO3 插件
我需要从其他插件的主体调用typo3插件并将其结果传递给模板。这是伪代码,描述了我想要实现的目标:
$data['###SOME_VARIABLE###'] = $someOtherPlugin->main();
$this->cObj->substituteMarkerArray($someTemplate, $data);
这可能吗?
谢谢!
I need to call typo3 plugin from other plugin's body and pass its result to template. This is pseudo-code that describes what I want to achieve doing this:
$data['###SOME_VARIABLE###'] = $someOtherPlugin->main();
$this->cObj->substituteMarkerArray($someTemplate, $data);
Is it possible?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
如果您使用整个 pi 构造(例如链接、标记函数等),它就不起作用,并且 TSFE 数据可能会损坏。
德米特里说:
http://lists.typo3.org/pipermail/typo3-english/2008-August/ 052259.html
It doenst work if you use the whole pi construct, e.g. for links, marker function etc, and the TSFE Data can be corrupted.
Dmitry said:
http://lists.typo3.org/pipermail/typo3-english/2008-August/052259.html
您应该使用 t3lib_div:makeInstance 方法。
TYPO3 的“powermail”扩展中有一个工作示例。
You should use t3lib_div:makeInstance method.
There is a working example from TYPO3's "powermail" extension.
@mitchiru 的回答很好,基本上是正确的。
如果您已经使用 Kickstarter 创建了外部扩展并且正在使用 pi_base,那么已经存在 tslib_cObj 的实例,并且整个构造变得更简单:
The answer of @mitchiru is nice and basically correct.
If you have created your outer extension with Kickstarter and you are using pi_base then there is already an instance of tslib_cObj and the whole construct becomes simpler:
首先,您必须在使用之前或在类之外包含您的插件类:
其次在您的代码中(以 main 为例)
Firstly, you have to include your plugin class, before using, or outside your class:
Secondly in your code (in the main as example)
这肯定会起作用(我已经检查过了): http: //lists.typo3.org/pipermail/typo3-english/2008-August/052259.html。
也许费迪尔的答案也是正确的,但我没有机会尝试。
干杯!
This will work for sure (I've checked this): http://lists.typo3.org/pipermail/typo3-english/2008-August/052259.html.
Probably Fedir's answer is correct too but I didn't have a chance to try it.
Cheers!