I'm having a problem with building the rule for a particular URL. Here's what I have in my system plugin:
//...
function onAfterInitialise() {
require_once '/path/to/myhelper.php';
$router = $this->app->getRouter();
$router->attachBuildRule(array('MyHelper', 'BuildRoute'));
$router->attachParseRule(array('MyHelper', 'ParseRoute'));
}
//...
In the myhelper.php:
class MyHelper {
//...
public static function buildRoute(&$router, &$uri) {
$uri->setPath('foobar');
$uri->setQuery(array());
}
//...
}
In another file, when I try to JRoute
any url, it adds the language code at the end instead of the beginning. For example:
echo JRoute::_('helloworld.php');
//this will print "/foobar/en/" instead of just "/en/foobar/" or possibly just "/foobar"
A few things:
I have the Joomla system plugin
System - Language Filter
enabled.Setting
Remove URL Language Code
to either Yes or No does not change the outcome.Disabling the plugin will remove the language code, but I can't do that.
The baffling part is, all other Joomla generated URLs (like the ones in the menu), have the language code in front. eg
mydomain.com/en/mylink
Also baffling is if I do not try to override the route, Joomla show the language code in the front for the same
JRoute::_('helloworld.php')
. It shows/en/helloworld
.
Any direction on this is greatly appreciated. Thanks in advance!