Redirect 使用组件&x27;s从';php';Joomla中的自定义插件
问题:如何在插件中启用来自组件的router.php的路由? 我正在开发一个自定义插件,它从默认用户配置文件重定向路由:Redirect 使用组件&x27;s从';php';Joomla中的自定义插件,redirect,joomla,routes,joomla-sef-urls,Redirect,Joomla,Routes,Joomla Sef Urls,问题:如何在插件中启用来自组件的router.php的路由? 我正在开发一个自定义插件,它从默认用户配置文件重定向路由: index.php?option=com_users&view=profile (SEF: /component/users/profile) 到我自己的组件,在那里我有额外的设置 index.php?option=com_mycomponent&view=profile (SEF: /alias/profile) 我的前端插件: class plgSys
index.php?option=com_users&view=profile (SEF: /component/users/profile)
到我自己的组件,在那里我有额外的设置
index.php?option=com_mycomponent&view=profile (SEF: /alias/profile)
我的前端插件:
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);
}
}
}
在“我的组件”中,所有链接均正确路由,即:
index.php?option=com\u mycomponent&view=profile=>/alias/profile
在插件中,JRoute将其翻译如下:
index.php?option=com\u mycomponent&view=profile=>/component/mycomponent/profile
不能使用:
- 核心黑客
- .htaccess
- Joomla重定向插件
<param name="menuitem" name="my_itemid" title="Target Itemid" description=""/>
这也是有效的
$route = JRoute::_('index.php?option=com_mycomponent&view=profile&Itemid='.$this->params->get('my_itemid') );
非常感谢你的帖子,尽管我已经找到了一个解决方案。我相信这将工作,但不是在一个以上的语言在网站上使用。为了解决这个问题,我使用了一个链接作为参数和当前语言,从“jos_menu”表中获取Itemid
$route = JRoute::_('index.php?option=com_mycomponent&view=profile&Itemid='.$this->params->get('my_itemid') );