简体   繁体   English

即时在Joomla文章中执行PHP?

[英]Execute PHP in Joomla Article on-the-fly?

This is for Joomla 2.5. 这是针对Joomla 2.5的。

There is a Joomla Article that needs to execute some PHP code to display as part of the Joomla Article. 有一条Joomla文章需要执行一些PHP代码才能显示为Joomla文章的一部分。 Is there a Joomla plug-in to allow embedding PHP code like which is supported in RSForm Pro with and ? 是否有一个Joomla插件可以嵌入PHP代码,例如RSForm Pro中使用and支持的PHP代码?

Or is it better to have a Joomla module written with PHP and have it displayed as part of the Joomla Article? 还是最好用PHP编写一个Joomla模块并将其显示为Joomla文章的一部分? Are there Extensions to help with this, or would a Joomla module need to be written from scratch to do this? 是否有扩展程序可以帮助您解决此问题,还是需要从头开始编写Joomla模块才能做到这一点? Thanks! 谢谢!

As @Rakesh Sharma mentioned, there are plenty of extensions that allow you to add PHP to an article. 正如@Rakesh Sharma提到的那样,有很多扩展允许您将PHP添加到文章中。 That is the quick solution if you only need to add a bit of code on a single article. 如果您只需要在一篇文章上添加一些代码,那就是快速的解决方案。

If you may need to execute the same code again in another article then you should write an extension to do it. 如果您可能需要在另一篇文章中再次执行相同的代码,则应编写一个扩展来执行。 It can be done with a module using {loadposition}, but the preferred method of changing the output of a component is with a plugin. 可以使用{loadposition}使用模块完成此操作,但是更改组件输出的首选方法是使用插件。 Then you would simply add the placeholder that triggers the plugin in the area you want to output to display. 然后,您只需在要输出显示的区域中添加触发插件的占位符。

We'd need more details on the code you want to execute to be able to give you the best solution. 我们需要您想要执行的代码的更多详细信息,以便为您提供最佳解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM