2013-11-26 32 views
0

我已經從我的CMS得到以下網址施工帶出一部分

domain.de/cmsfolder/page1/page2/function/my-news-headline 

domain.de/cmsfolder/page1/function/my-reference-headline 

我想條紋出來的功能,使我的網址是

domain.de/cmsfolder/page1/page2/my-news-headline 

domain.de/cmsfolder/page1/my-reference-headline 

並沒有導致404錯誤。

有人可以告訴我,如果這是可能的和如何?

或者也許有可能從我的網頁的任何網址中「出」功能?

最好的問候,並感謝您提前

回答

1

不是一個完美的解決方案,而這將在情況下工作,你只能在你的頁面控制器有1個動作(「myfunction的」):

這個添加到Page_Controller

private $actionName; 

private static $allowed_actions = array (
    'myfunction' 
); 

static $url_handlers = array(
    '' => 'myfunction' 
); 

public function init(){ 
    parent::init(); 

    $urlParams = $this->getURLParams(); 
    if(isset($urlParams['Action'])) { //might not be set when coming from '/' or '/home' 
     $this->actionName = $urlParams['Action']; 
    } 
} 

public function myfunction() { 
    //do something here with $this->actionName 
} 

現在,當你瀏覽到domain.de/cmsfolder/page1/page2/my-news-headline$actionName將被設置爲「我的新聞,標題」,並myfunction被調用,它的工作。

+0

謝謝,但我不明白如何處理$ actionName和['Action']。保持原樣?我的功能是來自DataObjectasPages模塊的「show」http://www.sspaste.com/paste/show/52975688ee774 – invictus