Hot answers tagged

4

To your first question "how can I make Joomla acknowledge my joomla.asset.json changes without reinstalling extensions?" I think it is not right that you have to reinstall the extension after every change in the file joomla.asset.json. It is only necessary the first time you add the joomla.asset.json file. So that Joomla registers this file. So ...


3

You need both PHP functions to do this work: json_encode : http://www.php.net/manual/de/function.json-encode.php json_decode: http://www.php.net/manual/de/function.json-decode.php Maybe something like this: <?php $arr = array (); $arr[name] = $this->form->getInput('name'); $arr[name2] = $this->form->getInput('name2'); echo ...


2

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"/> </fieldset&...


2

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.


2

To use format=json query parameter, the controller filename needs to be suffixed with the format, e.g. ajax.json.php. This is mentioned in the linked documentation: If you are developing an MVC component, save such a controller in a file called mycontroller.json.php and place it inside your controllers folder. That controller is automatically executed if ...


2

Resolved this as follows: In foreach, for the intro image, I replaced $introimage = $r->images; with $introimage = json_decode($r->images)->image_intro; For the date formatting, I added: use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\Language\Text; and replaced echo '<time datetime="' . $published . '" class="mb-2 text-muted&...


2

It's how Repeatable field stores its data. Pick a field to iterate over and use its key to access value of another field: foreach ($carousel_images['carouselimage'] as $key => $image) { // do something clever for each of the images '<img src="' . $image .'"><p>' . $carousel_images['carouselcaption'][$key] . '</p>'; } ...


2

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.


1

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 parent::display() in your controller code (ie in submit()). This will cause Joomla to look for a display() function in a ...


1

Joomla 3 There are a few existing places to get an API for Joomla! 3. https://techjoomla.com/rest-api-for-joomla https://www.selfget.com/products/jbackend.html Joomla 4 Or in Joomla! 4 is a full API https://www.joomdev.com/blog/entry/joomla-4-api-introduction https://docs.joomla.org/Joomla_Api_Specification https://magazine.joomla.org/all-issues/august-...


1

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.


1

Since your logos and urls exist in pairs, you can use a single loop over the logos and access the urls via the shared index. Code: (Demo) foreach ($jsonPartenaires['logo'] as $i => $logo) { $html = sprintf('<img src="%s">', $logo); if ($jsonPartenaires['url_partenaire'][$i]) { $html = sprintf( '<a href="%...


1

Although the other answer works, it's not very efficient. Instead everything but $query->values() call can be done outside the loop. This way multiple rows are inserted with a single database query: $query = $db->getQuery(true) ->insert($db->quoteName('#__table_name_')) ->columns($db->quoteName($columns)); foreach($arrayDecodedJson ...


1

The solution was simple. Put $query = $db->getQuery(true);, inside the foreach loop. Make an array in order to put inside the arrays values like : $values = array($db->quote($value['value1']),$db->quote($value['value2']),$db->quote($value['value3']),$db->quote($value['value4']) Then you make the query like so inside the foreach loop: ...


1

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. $...


1

I made it like this and it works. <?php $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); echo $AllExtraFields[0]->value; ?>


1

You're missing "$this->" You declared a class variable $OpenJS, so when you refer to it you need to use: $this->OpenJS Then beyond that, I don't think the values will get initialized correctly that way. Better is to move the initialization into the constructor: $this->OpenJS = "<script>"; By putting those lines into the constructor, the ...


1

The recommended replacement according to the Joomla documentation: Element Line Description \JResponse::setHeader() 83 3.2 Use JApplicationWeb::setHeader() instead https://api.joomla.org/cms-3/deprecated.html


Only top voted, non community-wiki answers of a minimum length are eligible