2012-03-20 192 views
0

我會喜歡一段代碼片段,它允許我攔截給定的URL,然後根據參數服務特定的頁面。繞過joomla菜單系統

這樣做的目的是,不管url的最後部分是否說'/ blah',我想要顯示的頁面。

ex 1: http://website/index.php/blah/ 
ex 2: http://website/index.php/blogcategory/articlex/blah/ 
ex 3: http://website/index.php/blogcategory/article5/blah/ 

都會顯示相同的文章。

感謝,

+0

這可以幫助你: 的http://計算器.com/questions/5010208/htaccess-redirect-permanent-www-domain-com -a-to-www-domain-com-ab – Shaz 2012-03-20 03:42:57

回答

0

你需要時觸發一個插件 'onAfterInitialise'。看一看:

http://docs.joomla.org/Plugin/Events/System#onAfterInitialise

您需要爲您的功能將類似於(未測試)的代碼:

/** 
* Do something onAfterInitialise 
*/ 
function onAfterInitialise() 
{ 
    // check for occurrence of string in url 
    $findme = 'blah'; 
    $myuri = JRequest::getURI(); 
    $tocheck = strpos($myuri, $findme); 

    if ($tocheck === true) { 
     $app = JFactory::getApplication(); 
     $app->redirect('/anywhereyouwant'); 
    } 
} 
+0

謝謝 - 我下週試試這個,讓你知道它是怎麼回事 – 2012-03-22 00:18:09