2

For now we have api/v1/content/articles, but this gets ALL the articles from the site. I do not need the whole list, just the featured articles.

Will we need to create an api-component as a temporary fix for this issue?

With the current state of Joomla4, how do you get the list of articles of a specific category? I do not see this stuff in the JDocs.

2 Answers 2

2

You can filter the API results just like the articles in Joomla's back-end: put ?filter[featured]=1 behind the URL.

In case you want to add multiple filters: prefix the first filter with a ? question mark and all others with an & ampersand.

So to display all Featured Articles from the News Category (let's assume that it's Category "10"):

api/v1//content/articles?filter[catid]=10&filter[featured]=1
2
  • There is not such filter in Joomla\Component\Content\Api\Controller. Not sure if adding this filter to the controller will work.... Commented Nov 21, 2022 at 18:54
  • Well, @peter adding if (\array_key_exists('featured', $apiFilterInfo)) { $this->modelState->set('filter.featured', $filter->clean($apiFilterInfo['featured'], 'INT')); } to Joomla\Component\Content\Api\Controller Did the work....but I missing something, or this is intentional to be out of this controller? If not, seen I should send a PR to github... Commented Nov 21, 2022 at 18:59
1

Thank to @pete the solution was simple after all. I already made the PR https://github.com/joomla/joomla-cms/pull/39273

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.