Handing in the Itemid is wrong. As you say yourself, that can change at
any time. You have to hand in the URL without the Itemid and then
calculate the correct Itemid by comparing the menu items for your
component with the query that your router got and choosing the right
one. Then you need to remove all query parameters that are already
encoded in your URL either via $segments or via the query of the menu
item. You are currently for example not removing the view parameter.
Joomla does NOT calculate the Itemid for you, but will only fallback on
the current active Itemid or the home Itemid. So calculating the right
one is the job of the component developer. Joomla also does not compare
the query with the given menu item and/or removes anything from it
(except the option parameter). So that, too, is your job. Since you hand
in a URL with the parameters "view" = "Appartments", Joomla appends that
to the URL that it gets from the menu item and that results in what you
got right now.
Hannes
Am 01.10.2015 um 14:46 schrieb 'Daniel Dimitrov' via Joomla! General
Development:
> Okay, you managed to totally confuse me :)
>
> If I pass a link to JRoute like this:
> 'index.php?option=com_capartments&view=Apartments&Itemid=105' I still
> don't have a correct link.
>
> As you can see I have an Itemid in the link, so why is the router
> building an url like this: /mieten?view=Apartments
>
> The link in the menu is exactly the same
> index.php?option=com_capartments&view=Apartments
>
>
>
>
joomla-dev-gene...@googlegroups.com <javascript:>
> > <javascript:>
> > > <mailto:
joomla-dev-gene...@googlegroups.com
> <javascript:>
> > an email to
joomla-dev-gene...@googlegroups.com
> <javascript:>
> > <mailto:
joomla-dev-gene...@googlegroups.com
> an email to
joomla-dev-gene...@googlegroups.com
> <mailto:
joomla-dev-gene...@googlegroups.com>.