1
問題:如何在插件中啓用組件的router.php中的路由?從Joomla的自定義插件中的'router.php'使用組件路由
我正在從默認用戶配置文件重定向路徑的自定義插件:
index.php?option=com_users&view=profile (SEF: /component/users/profile)
我自己的分量,我已經得到了額外的設置
index.php?option=com_mycomponent&view=profile (SEF: /alias/profile)
我的前置式end插件:
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);
}
}
}
在我的組件中,所有的鏈接都被路由到correctl ÿ即:
在插件JROUTE其翻譯如下的index.php選項= com_mycomponent &視圖=輪廓=>/別名 /簡檔
:
索引.php?option = com_mycomponent & view = profile =>/component/mycomponent/profile
不能使用:
- 核心的黑客
- 的.htaccess
- 的Joomla重定向插件
非常感謝您的文章,儘管我已經找到了靈魂。我確信這會起作用,但不是在現場使用多種語言的地方。爲了解決這個問題,我使用了一個鏈接作爲param和當前語言,從'jos_menu'表中獲取** Itemid ** – WooDzu