Question: How do I enable the Routes from my component's router.php in a plugin?
I'm working on a custom Plugin which redirects the route from default user profile:
index.php?option=com_users&view=profile (SEF: /component/users/profile)
to my own component where I've got additional settings
index.php?option=com_mycomponent&view=profile (SEF: /alias/profile)
my front-end plugin:
class plgSystemMyPlugin extends JPlugin
{
// constructor
function plgSystemMyPlugin( &$subject, $params ) {
parent::__construct( $subject, $params );
}
// run after the framework has loaded and the application initialize method has been called
function onAfterInitialise() {
// when component users and view profile are called
if( isset($_GET['option'], $_GET['view'])
&& $_GET['option'] == 'com_users'
&& $_GET['view'] == 'profile' )
{
$route = JRoute::_('index.php?option=com_mycomponent&view=profile' );
JFactory::getApplication()->redirect($route, null, null, true);
}
}
}
In my component all links are routed correctly ie:
index.php?option=com_mycomponent&view=profile => /alias/profile
in the plugin JRoute translates it as follows:
index.php?option=com_mycomponent&view=profile => /component/mycomponent/profile
can not use:
- core hacks
- .htaccess
- Joomla Redirect Plugin