? No Code Attached Yet
avatar liuvz
liuvz
1 Mar 2023

This is a more question than an issue report.

With the new RouterViewConfiguration we can set sef url parent section in the following way:

$category = new RouterViewConfiguration('category');
... ...
$this->registerView($category);
$foo = new RouterViewConfiguration('foo');
$foo->setKey('id')->setParent($category, 'catid');
$this->registerView($foo);

Everything is fine.

But how can we setParent, depending on differenct cases? For example, the item foo can be accessed from different parent view "category" and "tag":
index.php?option=com_foo&view=foo&id=1&catid=1
index.php?option=com_foo&view=foo&id=1&tagid=1

We would like to:
if url parameter catid exists: $foo->setParent($category, 'catid');
if url parameter tagid exists: $foo->setParent($tag, 'tagid');

Is it possible in Joomla 4? In Joomla 3 we can do it easily.
PS: Here we don't care about the advantage of SEO unique URL etc.

avatar liuvz liuvz - open - 1 Mar 2023
avatar liuvz liuvz - change - 1 Mar 2023
Labels Removed: ?
avatar joomla-cms-bot joomla-cms-bot - change - 1 Mar 2023
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 1 Mar 2023
avatar liuvz liuvz - change - 1 Mar 2023
The description was changed
avatar liuvz liuvz - edited - 1 Mar 2023
avatar Hackwar
Hackwar - comment - 1 Mar 2023

The code in J4 is basically identical to J3, so what works there should also work in J4. However, in general you can not define several parents for the same view. The views create a tree-based hierarchy. One view can have several child-views, but always only one parent view. I was just about to say that you could register the same view with 2 different viewconfiguration objects, but actually that currently is not possible. We could add that by adding an alias to the viewconfiguration object, but that most likely wouldn't come before Joomla 5.0.

avatar Hackwar Hackwar - change - 1 Mar 2023
Labels Added: ?
avatar Hackwar Hackwar - labeled - 1 Mar 2023
avatar liuvz
liuvz - comment - 1 Mar 2023

Ok thanks for your reply. Actually the router which I mentioned above was the old buildRoute / parseRoute from Joomla 2.5 and compatible with Joomla 3. You are right, in Joomla 3 it is almost identical.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/39974.

Add a Comment

Login with GitHub to post a comment