You need both PHP functions to do this work:
Maybe something like this:
$arr = array ();
$arr[name] = $this->form->getInput('name');
$arr[name2] = $this->form->getInput('name2');
I think you probably want to use the session - see https://docs.joomla.org/How_to_use_user_state_variables.
Store the data in a session variable, then do a redirect to your component P, and then P retrieves them from the session data.
Don't forget to clear the relevant session data after you've finished with it.
Enclose those two fields in a element in your form xml file.
<fields label="COM_COMPONENTNAME_FIELDNAME_FIELDSET_LABEL" name="fieldname">
<fieldset label="COM_COMPONENTNAME_FIELDNAME_FIELDSET_LABEL" name="basic">
<field name="name" type="text" label="name"/>
<field name="name2" type="text" label="name"/>
Start by extracting the extra_fields column's json string from #__k2_items table at the row of your choosing, then decode it. Each row from the array (generated by decoding json), will have two elements having respective keys: id and value .
I don't quite know the full picture of what you are trying to do, but I can help you to relate and extract the data.
I made it like this and it works.
$db = JFactory::getDBO();
$articleid = JRequest::getInt('id');
$db->setQuery('SELECT extra_fields FROM #__k2_items WHERE id='.$articleid);
$AllExtraFields = $db->loadResult();
$AllExtraFields = json_decode($AllExtraFields);
The recommended replacement according to the Joomla documentation:
Element Line Description
\JResponse::setHeader() 83 3.2 Use JApplicationWeb::setHeader() instead
What you should do is include &format=json in your URL. This tells Joomla that you want a JSON response rather than HTML, and it won't run (subsequently) your template to produce all your page HTML.
The usual approach is to call
in your controller code (ie in submit()). This will cause Joomla to look for a display() function in a ...
Joomla! 4.0 will have Web Services.
In 3.x, without using extensions or custom code, there's no way to do this for single articles. For article listings (category views) you could use RSS/Atom feed by accessing category view with format=feed parameter appended.
Only components that specifically provide a JSON response are accessible in the JSON format. Modules are not (by design) directly addressable hence you can not call them directly, therefore, no JSON format option.
You could build a plugin to gain access to the data you wanted but that would be a 100% custom built option.