Skip to content

Issue #89 feat: Category plugin enhancements#90

Merged
manojLondhe merged 2 commits intotechjoomla:masterfrom
manojLondhe:master
Jan 10, 2019
Merged

Issue #89 feat: Category plugin enhancements#90
manojLondhe merged 2 commits intotechjoomla:masterfrom
manojLondhe:master

Conversation

@manojLondhe
Copy link
Member

  • Update get single category api
  • Update get category list api

- Update get single category api
- Update get category list api
@manojLondhe manojLondhe requested a review from coolbung January 3, 2019 10:27
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
Copy link
Member

@coolbung coolbung Jan 3, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$input = $app->input;

// Important to get from input directly and not from $input->get->get()
$id = $input->get('id', 0, 'int');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please support getting the category by either id or alias, so both /categories/category/59 and /categories/category/sports should work

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@coolbung

How do we differentiate between if an alias is set or an id is set?

Consider an example with a

  1. category having id as 2
  2. and another category having alias as sports-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

Copy link
Member

@coolbung coolbung Jan 5, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can think of 2 options

  1. Don't typecast the id as int. if the id is numeric assume it to be a id, otherwise assume it to be alias.
  2. 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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants