Joomla组件:不带html的输出 [英] Joomla component: Output without html
问题描述
我正在为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.html.php
相同的 view.raw.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的输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!