I need to have the output of a PHP snippet in a Plone site. It was delivered to be a small library that has a display() function, in PHP, that outputs a line of text. But I need to put it in a Plone site. Do you have any recommendations?
我需要在Plone站点中输出PHP代码段。它被提供为一个小型库,在PHP中有一个display()函数,用于输出一行文本。但我需要把它放在Plone网站上。你有什么建议?
I was thinking a long the lines of having a display.php that just runs display() and from the Plone template to download that URL and output the content. Do you think it might work? What methods of hitting a URL, retrieve the content and outputting can I use from inside a Plone template?
我正在考虑使用display.php来运行display()和从Plone模板下载该URL并输出内容。你觉得它可行吗?我可以在Plone模板中使用哪些方法来访问URL,检索内容和输出?
One important and critical constraint is that the output should be directly on the HTML and not an an iframe. This is a constraint coming from the outside, nothing technical.
一个重要且关键的约束是输出应该直接在HTML上,而不是iframe。这是来自外部的约束,没有技术。
3 个解决方案
#1
1
Another option is to run the PHP script on the server using os.popen, then just printing the output. Quick and dirty example:
另一种选择是使用os.popen在服务器上运行PHP脚本,然后只打印输出。快速而肮脏的例子:
import os
print os.popen('php YourScript.php').read()
#2
1
Well, use AJAX to call the PHP script (yes, you will need apache) and display the output. Adding a custom JS to plone is trivial and this abstract the technology issue.
好吧,使用AJAX调用PHP脚本(是的,你需要apache)并显示输出。将自定义JS添加到plone是微不足道的,这是抽象的技术问题。
Just be sure this is not a critical feature. Some users still deactivate JS and the web page should therefor degrade itself nicely.
请确保这不是一个关键功能。一些用户仍然停用JS,因此网页应该很好地降级。
#3
0
Probably the easiest way: install windowz inside your site. That way you get a page with an iframe in your plone layout. Make sure the php script outputs a regular html page and configure your windowz page with that url. Done.
可能是最简单的方法:在您的网站内安装windowz。这样,您就可以在plone布局中获得包含iframe的页面。确保php脚本输出常规html页面并使用该URL配置windowz页面。完成。
Works great for existing in-company phonebook applications and so.
适用于现有的公司内部电话簿应用程序等。
#1
1
Another option is to run the PHP script on the server using os.popen, then just printing the output. Quick and dirty example:
另一种选择是使用os.popen在服务器上运行PHP脚本,然后只打印输出。快速而肮脏的例子:
import os
print os.popen('php YourScript.php').read()
#2
1
Well, use AJAX to call the PHP script (yes, you will need apache) and display the output. Adding a custom JS to plone is trivial and this abstract the technology issue.
好吧,使用AJAX调用PHP脚本(是的,你需要apache)并显示输出。将自定义JS添加到plone是微不足道的,这是抽象的技术问题。
Just be sure this is not a critical feature. Some users still deactivate JS and the web page should therefor degrade itself nicely.
请确保这不是一个关键功能。一些用户仍然停用JS,因此网页应该很好地降级。
#3
0
Probably the easiest way: install windowz inside your site. That way you get a page with an iframe in your plone layout. Make sure the php script outputs a regular html page and configure your windowz page with that url. Done.
可能是最简单的方法:在您的网站内安装windowz。这样,您就可以在plone布局中获得包含iframe的页面。确保php脚本输出常规html页面并使用该URL配置windowz页面。完成。
Works great for existing in-company phonebook applications and so.
适用于现有的公司内部电话簿应用程序等。