简体   繁体   English

Joomla 3-从控制器任务返回原始数据

[英]Joomla 3 - Return raw data from controller task

Can someone tell me the correct way to return raw data without html from a task in my component? 有人可以告诉我从组件中的任务中不使用html返回原始数据的正确方法吗?

I've tried index.php?option=com_mycomponent&task=mysubcontroller.mytask&format=raw and index.php?option=com_mycomponent&task=mysubcontroller.mytask&tmpl=component 我已经尝试过index.php?option=com_mycomponent&task=mysubcontroller.mytask&format=rawindex.php?option=com_mycomponent&task=mysubcontroller.mytask&tmpl=component

But everything returns with html. 但是一切都以html返回。

Can't seem to find anything written down anywhere to address this, which seems to be a recurring theme for me with Joomla! 似乎找不到任何地方写下来解决此问题的方法,对于Joomla来说,这似乎是我反复出现的主题!

Hope someone can help as I've had to create a new template called raw.php with only the jdoc include tag and call it like so: 希望有人可以提供帮助,因为我raw.php不仅使用jdoc include标签创建一个名为raw.php的新模板,并按如下方式调用它:

index.php?option=com_mycomponent&task=mysubcontroller.mytask&tmpl=raw

That's a hack as far as I'm concerned because it is not a solution that is self contained within the component. 就我而言,这是一个hack,因为它不是组件本身包含的解决方案。

Hope someone can enlighten me. 希望有人能启发我。

Many thanks... 非常感谢...

Ok so I've found out a little more about how to . 好的,我已经了解了些什么。

After a bit of searching on Stack Overflow, I found this which allows you to output just JSON: 在对Stack Overflow进行了一些搜索之后,我发现它可以让您仅输出JSON:

Joomla Controller Task that returns JSON data 返回JSON数据的Joomla控制器任务

I feel a bit foolish for not seeing this before. 我以前没看到这个感觉有点愚蠢。 Does anyone know if using JFactory::getApplication()->close(); 有谁知道是否使用JFactory::getApplication()->close(); will work with anything other than JSON? 可以使用JSON以外的其他功能吗?

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

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