Hot answers tagged

8 votes
Accepted

How to use joomla.asset.json correctly?

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 ...
astridx's user avatar
  • 439
3 votes
Accepted

Input JSON strips HTML

There is no json filter which causes default filter to be applied, stripping away HTML. Use a different filter. This answer shows some examples. Using array filter should work: $input = $this->...
Sharky's user avatar
  • 11.1k
2 votes

Execute Joomla CLI script to bulk import JSON data to articles

I found when running CLI scripts that other things that you don't really need to execute, i.e. plugins, will cause failures because they don't check themselves to disable if they are running under a ...
Irata's user avatar
  • 3,822
2 votes
Accepted

Invalid controller class from custom component ajax call to json method

In J4 default MVC factory uses PSR-4 autoloading. So InputDataController.json.php filename is invalid, your controller class will not be found at all. Secondly, default component dispatcher doesn't ...
Sharky's user avatar
  • 11.1k
2 votes

Integrate external news content API into com_content articles

Do you want to do a fetch only from the news website (GET requests only) or do you need to push back information from your Joomla! 3 website eg (POST request) ? Joomla 3 HTTP Client is the same than ...
mralexandrelise's user avatar
2 votes
Accepted

How to output just raw json from my Joomla controller for Ajax requests?

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 ...
Sharky's user avatar
  • 11.1k
2 votes
Accepted

Query database and show latest 3 articles from __content

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: ...
RustyJoomla's user avatar
  • 2,078
2 votes
Accepted

Show images and caption from array as images in carousel

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 ...
Sharky's user avatar
  • 11.1k
2 votes
Accepted

Crawling Joomla websites without parsing website's html

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 ...
Sharky's user avatar
  • 11.1k
2 votes
Accepted

How to pass a JSON file from a Plugin to a Component?

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 ...
Robbie Jackson's user avatar
2 votes

Params field value for extension in database is inconsistant when using subform & default values, it returns either a string or an object, how to fix?

When your plugin is installed the manifest(.xml) file is parsed and a fairly basic process of saving your values into the #__extension table occurs. In the case of the params the default= is being ...
Irata's user avatar
  • 3,822
2 votes
Accepted

Decode json strings from a database table column

It looks like you are mangling valid json data with explode() (the wrong tool for the job). You just need to call json_decode() on each string. This can be done with array_map() or a classic foreach()...
mickmackusa's user avatar
  • 4,791
1 vote
Accepted

Add extra values to the the document in JSON API Response

Joomla\CMS\MVC\View\JsonApiView view class is meant for generating JSON:API compliant output. For generic/custom JSON you can use the Joomla\CMS\MVC\View\JsonView class instead.
Sharky's user avatar
  • 11.1k
1 vote

Execute Joomla CLI script to bulk import JSON data to articles

Here is the final working code courtesy of @mickmackusa. It took the addition of $app = JFactory::getApplication( 'site' ); to fix the Failed to start application error in the command line. /** * A ...
Mike Hermary's user avatar
1 vote
Accepted

Ajax Request returning the whole page not a specifc value

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 ...
Robbie Jackson's user avatar
1 vote

Crawling Joomla websites without parsing website's html

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 ...
Eoin's user avatar
  • 1,909
1 vote

How to get data from core components and modules formatted as JSON?

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 ...
manuman's user avatar
  • 11
1 vote
Accepted

Create dynamic html markup from values in repeatable field json

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) { $...
mickmackusa's user avatar
  • 4,791
1 vote
Accepted

Insert multiple rows into a database table using a loop

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:...
Sharky's user avatar
  • 11.1k
1 vote

Insert multiple rows into a database table using a loop

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']),$...
leno1232's user avatar
1 vote

How to display specific K2 extra field of current item with k2 tool module

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 ...
mickmackusa's user avatar
  • 4,791
1 vote
Accepted

How to display specific K2 extra field of current item with k2 tool module

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 ...
okisan's user avatar
  • 55
1 vote

Controller Joomla - Output Class construct for color css style

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 ...
Arlen's user avatar
  • 802
1 vote
Accepted

How to set HTTP header on Joomla's JSON response?

The recommended replacement according to the Joomla documentation: Element Line Description \JResponse::setHeader() 83 3.2 Use JApplicationWeb::setHeader() instead ...
mickmackusa's user avatar
  • 4,791

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