Issue #89 feat: Category plugin enhancements#90
Issue #89 feat: Category plugin enhancements#90manojLondhe merged 2 commits intotechjoomla:masterfrom
Conversation
manojLondhe
commented
Jan 3, 2019
- Update get single category api
- Update get category list api
- Update get single category api - Update get category list api
| Alternatively, you can call this API as follow (assuming you have created a menu with alias as 'api' for com_api) | ||
|
|
||
| ```http | ||
| GET /api/categories/categories |
There was a problem hiding this comment.
Can this be /categories/all/:extension. The value of extension will be available in the id param. Not ideal, but that makes the sef URL semantic.
There was a problem hiding this comment.
need router support here as well as described at https://github.com/techjoomla/com_api-plugins/pull/90/files#r245647296 @coolbung
| $input = $app->input; | ||
|
|
||
| // Important to get from input directly and not from $input->get->get() | ||
| $id = $input->get('id', 0, 'int'); |
There was a problem hiding this comment.
Please support getting the category by either id or alias, so both /categories/category/59 and /categories/category/sports should work
There was a problem hiding this comment.
How do we differentiate between if an alias is set or an id is set?
Consider an example with a
- category having
idas2 - and another category having
aliasassports-2
Current com_api router only handles id, how will it work for alias?
in above two cases:
$id = $input->get('id', 0, 'int'); will return 2 as $id
There was a problem hiding this comment.
I can think of 2 options
- Don't typecast the id as int. if the id is numeric assume it to be a id, otherwise assume it to be alias.
- Support a X-Identifier header. The value for this header can be id (default) or alias. This tells the plugin which record to update. This method is already implemented in the user edit plugin by @twsvaishali
There was a problem hiding this comment.
- or can we add trigger to let extend com_api router, something like
onApiRoute (&segments, &$vars)
and let plugins set vars as needed
I tried this out and I got both id and alias to work