Note that there are some explanatory texts on larger screens.

plurals
  1. POJoomla 2.5 site task will not fire
    primarykey
    data
    text
    <p>Here is my issue. I have a form that I want to send data to a JSON task. However no matter what I do the task will not run. I just get the following error:</p> <p><code>Invalid controller: name='controls', format='json'</code></p> <p>As far as I can see there is nothing that should prevent the controller from running. Here is the code.</p> <pre><code>class HelloWorldControllerControls extends JController{ /*function __construct(){ parent::__construct(); }*/ public function postal(){ JFactory::getDocument()-&gt;setMimeEncoding( 'application/json' ); JResponse::setHeader('Content-Disposition','attachment;filename="status.json"'); //$postal = JRequest::getVar('postal_code',false); //$dispatcher = JDispatcher::getInstance(); //$saveLocalCookie = $dispatcher-&gt;trigger('onSavePostalCode', array('code'=&gt;$postal)); echo json_encode(array('success'=&gt;true)); jexit(); } } </code></pre> <p>This is of course in the site <code>controllers</code> folder and named <code>controls.json.php</code></p> <p>I have matched this with another controller I am using in the admin panel that does pretty much the exact same thing, but it works in admin, not in the site.</p> <p>The JRoute I am using to try to call this is.</p> <p><code>index.php?option=com_helloworld&amp;task=controls.postal&amp;format=json</code></p> <p>Anything I may be overlooking?</p> <p>EDIT:</p> <p>To clarify, I need to call the task directly, as all I will be doing is outputting raw data in JSON format, there is no need for a view, only a model an controller. Currently since I am still in testing there is no need for the model yet.</p> <p>EDIT 2:</p> <p>Found part of an answer, but am going to leave it open as this answer is not really that great. Its impossible based on how Joomla sets up MVC in the "site" portion (based on my tests). It always looks for view first, then controller. I could only get the task to fire by making sure a view was set. There is a chance I am wrong and misled from my tests because an open source framework not building MVC correctly seems illogical.</p> <p>So in order to fix this you need to use a "view" as a "controller".</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload