Hello Lucas,
you can not register one view twice in the router. Simply because that
would mean that there are 2 ways to reach the view and that would mean
that the URLs would not be unique. You would effectively create
duplicate content. I think what you want, is to simply not register the
note view for the tag view.
Hannes
Am 05.02.2018 um 13:15 schrieb Lucas Sanner:
> Hi all,
>
> I'm trying to use the new Joomla router with my component but I'm stuck
> with the adding of extra views.
> According to the Joomla documentation I first set up my router's
> constructor like this:
>
> |
> ...
> $categories =newJComponentRouterViewconfiguration('categories');
> $categories->setKey('id');
> $this->registerView($categories);
> $category =newJComponentRouterViewconfiguration('category');
> $category->setKey('id')->setParent($categories,'catid')->setNestable()->addLayout('blog');
> $this->registerView($category);
> // The view for the item of my component.
> $note =newJComponentRouterViewconfiguration('note');
> $note->setKey('id')->setParent($category,'catid');
> $this->registerView($note);
> ...
> |
>
>
> So far so good, the new router works fine with my component and the url
> query segments are properly built and parsed.
> But, the problem is that my component has also 2 extra views (tags and
> tag) which also have the component item (note) as children.
>
> |
> ...
> $tags =newJComponentRouterViewconfiguration('tags');
> $tags->setKey('id');
> $this->registerView($tags);
> $tag =newJComponentRouterViewconfiguration('tag');
> $tag->setKey('id')->setParent($tags,'tag_id')->setNestable()->addLayout('blog');
> $this->registerView($tag);
> // The view for the item of my component.
> $note =newJComponentRouterViewconfiguration('note');
> $note->setKey('id')->setParent($tag,'tag_id');
> $this->registerView($note);
> ...
> |
>
>
> Things become tricky now as it seems not possible to register all the
> views (categories, category, tags and tag) at the same time in the
> constructor (I tried and experienced some application crashes). Moreover
> my component item now ends up with 2 different parents which looks a bit
> weird.
>
> One solution would be to register the router's views on the fly
> according to the view contained in the current url query, but
> unfortunatly I couldn't get it from the router's constructor.
> The other solution would be to register the router's views from another
> location where I can retrieve the current view. But where and is it
> possible ?
>
> May be is there another way to get it work ?
>
> Any help or information would be very much appreciated.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Joomla! General Development" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to
joomla-dev-gene...@googlegroups.com
> <mailto:
joomla-dev-gene...@googlegroups.com>.
> To post to this group, send email to
joomla-de...@googlegroups.com
> <mailto:
joomla-de...@googlegroups.com>.
> Visit this group at
https://groups.google.com/group/joomla-dev-general.
> For more options, visit
https://groups.google.com/d/optout.