Joomla router based on cookie

152 Views Asked by At

How can I change current Joomla URL in plugin?

For example I have a cookie set $_COOKIE['mycity'] which equals barnaul

I need to create Joomla plugin that is able to replace current URL with new one.

For example replace

http://www.myjoomlawebsite.com/about.html

with

http://www.myjoomlawebsite.com/barnaul/about.html

Right now I'm trying my best to understand how JoomFish does that... I guess I need to dig into JURI->setPath.

1

There are 1 best solutions below

0
On BEST ANSWER

Try using JRouter::attachBuildRule(). You should pass it a callback function which will take two arguments. The first is an instance of JRouter, the second is an instance of JURI (both passed by reference). So then, your function should check the cookie value and update the path of the JURI instance as needed.