具有 JFactory 访问权限的 Joomla 图像渲染扩展
是否可以为 joomla 编写扩展或使用一些类似于 jumi 的现有插件来渲染 png 图像,但可以完全访问用户数据(使用 JFactory)? 换句话说,今天创建一个根据传递的参数呈现公共图像的 php 脚本不是问题。但如果我想访问用户数据并检查用户是否登录,这就成了一个问题。
Is it possible to write an extension for joomla or use some existing plugin similar to jumi to be able to render for instance a png image but with full access to user data (with JFactory)?
In other words today it's not a problem to create a php script that renders a public image based on parameters passed. But if I want to access user data and check wether the user logged in or not it becomes a problem.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您将需要创建一个在查询字符串中使用
format=raw
的组件(或组件的一部分)。您还需要使用JDocument
对象将 MIME 类型设置为 image/png。为此,请在名为image
的组件中创建一个视图(或您想要的任何名称)。然后,创建view.raw.php
,而不是创建view.html.php
文件。在该文件内,添加如下代码:您不需要需要使用
default.php
创建一个tmpl
文件夹,因为您不输出任何内容标记。You will want to create a component (or a part of one) that uses
format=raw
in the query string. You'll also want to use theJDocument
object to set the MIME type to image/png. To do this, create a view in the component calledimage
(or whatever you'd like). Then, instead of creating aview.html.php
file, createview.raw.php
. Inside that file, add code like this:You do not need to create a
tmpl
folder withdefault.php
as you're not outputting any markup.我非常确定这是可能的。我讨厌周围没有任何可以绝对确定的东西,但我突然想到(已经有一段时间了!)我认为你正在寻找“原始输出”。
您应该能够在 URL 的查询字符串上添加一些内容来控制 Joomla“内容”的输出,而这些内容不完全是您的代码。据我记得,您需要在查询字符串中添加类似“&output=raw&no_html=1”的内容。
希望这至少能让你到达某个地方......
I am pretty sure that this is possible. I hate not having anything around me to be absolutely sure, but off the top of my head (and it's been a while!) I think you're looking for 'raw output'.
You should be able to add something on the URL's query string to control the output of the Joomla 'stuff' that is not your code exactly. From what I remember, you need to add something like '&output=raw&no_html=1' to the query string.
Hopefully that will at least get you somewhere...
感谢所有答案,尤其是jlleblanc。在他们的帮助下,我最终得到了一个使用现有众所周知的扩展的解决方案。
我们所需要的只是生成 php 输出的任何组件。我尝试过使用 Jumi,但它也应该适用于任何其他。
我们在 Jumi 组件(在 Jumi 应用程序管理器中)中创建一个项目,该项目会生成图像,例如填充矩形。
根据组件规则添加后,我们有一个到该组件项目的链接
其中 fileid=3 是基于实际 id 的字符串物品
如果我们只是按原样使用这个 url,我们将得到通常的 Joomla 布局,其中扭曲的页面将 png 流显示为文本(实际上视觉上不太舒服),但最后的一个小技巧“format=raw”会给我们这样的结果:需要。
就这样。之后浏览器中就会显示正确的图像。
再次感谢
Thanks to all answers, especially jlleblanc. With the help of them I ended up with a solution using existing well-known extension(s).
All we need is any component that produces php-output. I tried with Jumi, but also it should work with any other.
We create an item in Jumi component (in Jumi Applications Manager ) that produces an image, for example filled rectangle
After adding according to the component rule we have a link to this component item
Where fileid=3 is the string based on actual id of the item
If we just use this url as it is we will get usual Joomla layout with distorted page showing png stream as text (not so visually comfort actually), but a little trick "format=raw" at the end will give us the result that we need.
That's all. After that the correct image is displayed in the browser.
Thanks again