質問: プラグインでコンポーネントのrouter.phpからルートを有効にするにはどうすればよいですか?
デフォルトのユーザープロファイルからルートをリダイレクトするカスタムプラグインに取り組んでいます:
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_mycomponent&view=profile => /alias /profile
プラグイン JRoute では、次のように変換されます。
index.php?option=com_mycomponent&view=profile => /component/mycomponent /profile
使えない:
- コアハック
- .htaccess
- Joomlaリダイレクトプラグイン