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
  • Please edit your answer to statically present the resolving changes from github.com/joomla/joomla-cms/pull/39273/commits/… so that future researchers don't need to link-chase to understand what you did. Commented Nov 22, 2022 at 0:07
  • Thanks for your PR! Commented Nov 22, 2022 at 9:12

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.