问题描述
我正在为 Joomla 2.5 开发 Joomla 组件.因为它应该输出 XML,所以我绝对不想显示周围的模板.
I am developing a Joomla component for Joomla 2.5. Since it's supposed to output XML, I most defenitely don't want to display the surrounding template.
我尝试附加到网址:
- ?tmpl=component
- ?format=raw
- ?tmpl=raw
但是第一个会在内容输出周围生成一些 HTML,第二个会给我一个 500 错误.第三个根本不产生任何输出.我假设它正在寻找一个名为raw"的模板,因为我放在那里的任何其他乱码模板名称都会给我相同的结果.
But the first will generate some HTML around the content output and the second gives me a 500 error. The third one generates no output at all. I assume it's looking for a template named "raw", because any other gibberish template name I put there gives me the same result.
如何在没有任何附加 Joomla + 模板 HTML 的情况下从我的组件输出 XML?
How can I output XML from my component without any of the additional Joomla + template HTML?
推荐答案
在 Joomla!1.5 你所要做的就是添加?tmpl=component&format=raw
而是实现原始显示
In Joomla! 1.5 all you had to do is add ?tmpl=component&format=raw
but to achieve raw display
在 Joomla!2.5 您需要制作 view.raw.php 文件,该文件可以与您现有的 view.html.php
相同,但这取决于您的需要.而且在控制器中,您必须手动实例化原始视图,因为默认类型是 html.
In Joomla! 2.5 you need to make view.raw.php file which can be identical to your existing view.html.php
, but that depends on your needs. And also in the controller you have to manually instantiate raw view because default type is html.
您可以在文件 administrator/components/com_banners/controllers/tracks.raw.php
中找到一个很好的例子,它是 Joomla 附带的默认组件的一部分.
A very good example you can find in file administrator/components/com_banners/controllers/tracks.raw.php
which is the part of default components shipped with Joomla.
这篇关于Joomla 组件:没有 html 的输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!