Create an extension with the category type such as extension=com_myextension.section (for example, you have two different types of content needs category system in same extension)
Use the same router. Here is the routing in my router.php
$category = new RouterViewConfiguration('category');
$category->setKey('id')->addLayout('section')->setParent($categories, 'catid')->setNestable();
$this->registerView($category);
Registered rules as below:
$this->attachRule(new JComponentRouterRulesMenu($this));
$this->attachRule(new JComponentRouterRulesStandard($this));
$this->attachRule(new JComponentRouterRulesNomenu($this));
Sef URL which is correctly formatted like /menualias/category-alias
/menualias?view=category&id=83&layout=section
Joomla 3.9.11, PHP 7.2, New router (no legacy)
Labels |
Added:
?
|
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2022-11-14 19:12:26 |
Closed_By | ⇒ | Hackwar | |
Labels |
Added:
No Code Attached Yet
Removed: ? |
Yes, the router does "support" this, but I fear the way @corejoomla is using this is wrong. First of all, selecting the right ID or alias for the segment is something that you have to do in your get<View>Id
and get<View>Segment
methods. I don't see your code for that here. Second, if you would be using categories with the same component, but different sections, you would generally have to use different views for the different sections, not just differing layouts. So you would have a view category
and a view productgroups
for example and internally they use the category system, but they are different views, which are displayed entirely. Otherwise how should the router know that in case 1 you mean [component].[section1] and in case 2 you mean [component].[section2]? After all, you are also not bound to the core Joomla category system. You can use any data structure or objects which implement the right interface and methods.
To be honest, this looks like rather a case of bad documentation from our side, than a bug in the system. I promise to improve the documentation, but I fear for @corejoomla this is coming a bit late with 3 years delay. I'm very sorry for that. I'm closing this issue here for now. If you think this has been closed in error, please respond and I'll open it again.
@Hackwar Does the router already support categories with sections? Can you help here?