User tests: Successful: Unsuccessful:
Pull Request for Issue # .
Functionality for filtering articles by workflow stage exists in the admin panel, but that filter is missing from the Content API. This adds support for the stage
filter to the Content API.
Test 1: Filter for articles at a specific workflow stage
GET /api/index.php/v1/content/articles?filter[stage]=1
Test 2: No filter parameter
GET /api/index.php/v1/content/articles
Test 3: Combined with other filters
GET /api/index.php/v1/content/articles?filter[stage]=1&filter[category]=2
While there was support for filtering articles by workflow stage in the admin panel, the Content API did not support this functionality.
The Content API now supports the filter[stage]
parameter to filter articles by workflow stage.
Please select:
Documentation link for docs.joomla.org:
No documentation changes for docs.joomla.org needed
Pull Request link for manual.joomla.org:
No documentation changes for manual.joomla.org needed
Status | New | ⇒ | Pending |
@exlemor After playing around for a bit, I think I found what's happening. Good (bad?) news, this behavior exists prior to this PR.
In ArticlesModel the category filtering is done with the category's lft
and rgt
values, rather than explicitly comparing the ID. I think this is to include items in subcategories. When using filter[category]=1
it pulls the values from category ID 1 (the ROOT category) in the database, and all categories are included. When using filter[category]=0
, the filter is not applied and is ignored.
All in all, to me this looks like it's intended behavior.
@itsnewtjam Hi James, I fear there might be some fixes that need to be made...
When testing Test 1, I seem to get what is expected,
When testing Test 2, I seem to get what is expected but
When testing Test 3, I seem to get what is expected for 'some' endpoints but not others:
https://www.domain.com/_j540/api/index.php/v1/content/articles?filter[stage]=7&filter[category]=2
(Uncategorised - no articles) ----> no results as I would expect
https://www.domain.com/_j540/api/index.php/v1/content/articles?filter[stage]=7&filter[category]=3
https://www.domain.com/_j540/api/index.php/v1/content/articles?filter[stage]=7&filter[category]=4
https://www.domain.com/_j540/api/index.php/v1/content/articles?filter[stage]=7&filter[category]=5
https://www.domain.com/_j540/api/index.php/v1/content/articles?filter[stage]=7&filter[category]=6
https://www.domain.com/_j540/api/index.php/v1/content/articles?filter[stage]=7&filter[category]=7
(No Article Category exists with that ID, therefore no articles) ----> no results as I would expect
https://www.domain.com/_j540/api/index.php/v1/content/articles?filter[stage]=7&filter[category]=8
(Blog category ID:8, and articles ID 3,4,5,6,14) ----> articles listed 14,6,5,4,3 as expected
https://www.domain.com/_j540/api/index.php/v1/content/articles?filter[stage]=7&filter[category]=9
(Help category ID: 9, and no articles in stage 7) --> no results as I would expect
https://www.domain.com/_j540/api/index.php/v1/content/articles?filter[stage]=7&filter[category]=10
(Joomla category ID: 10, and no articles in stage 7) --> no results as I would expect
https://www.domain.com/_j540/api/index.php/v1/content/articles?filter[stage]=7&filter[category]=11
(Typography category ID: 11, and no articles in stage 7) --> no results as I would expect
https://www.domain.com/_j540/api/index.php/v1/content/articles?filter[stage]=7&filter[category]=12
(Category (en-GB) category ID: 12, and no articles in stage 7) --> no results as I would expect
https://www.domain.com/_j540/api/index.php/v1/content/articles?filter[stage]=7&filter[category]=13
(Catégorie (fr-fr) category ID: 13, and no articles in stage 7) --> no results as I would expect
https://www.domain.com/_j540/api/index.php/v1/content/articles?filter[stage]=1&filter[category]=10
(Joomla category ID: 10, and articles ID 7,8,9 in stage 1) --> articles listed 9,8, and 7 as expected
BUT why?
https://www.domain.com/_j540/api/index.php/v1/content/articles?filter[stage]=7&filter[category]=0
https://www.domain.com/_j540/api/index.php/v1/content/articles?filter[stage]=7&filter[category]=1
results in articles 14,6,5,4 and 3 show up in the results, even though there is no Category 1 or 0 defined in the backend?
https://www.domain.com/_j540/api/index.php/v1/content/articles?filter[stage]=1&filter[category]=1
(stage=1 - Basic Workflow, category 1 does not exist that I can find) yet the results are articles 1,2,7,8,9,10,11,12,13 ?
I may be missing something
using Postman Desktop Mac app.