2011-08-01 10 views
0

私のアプリがプロファイル名をロードしたい場合、次のようにします:www.mydomain.com/simonここで、simonはコントローラではなく、プロファイルを表示するユーザのユーザ名は可能ですか?コントローラをロードせずにzend、access appにアクセスしますか?

class ProfileController extends Zend_Controller_Action { 


    public function init() { 

    } 

    public function indexAction(){ 

     echo $this->_request->getParam('profileuser'); 

これは私がユーザーを表示できる場所です。

} 

か何か... ProfileControllerを推定

答えて

3

この目的でZend_Routeを使用することがあります。

ちょうどあなたのアプリケーションのブートストラップに以下を追加します。Zend_Controller_Routerhereを使用して上の

protected function _initRoutes() 
{ 
    $frontController = Zend_Controller_Front::getInstance(); 
    $router = $frontController->getRouter(); 

    $router->addRoute('profile', new Zend_Controller_Router_Route(
     ':profileuser', 
     array('module' => 'default', 'controller' => 'profile', 'action' => 'index') 
    )); 
} 

詳しい情報を。

+0

が完了しました。 Zend_Controller_Router_Exception:profileuserは、522行目のC:¥wamp¥www¥discoverd2¥library¥Zend¥View¥Helper¥Navigation¥HelperAbstract.phpには指定されていません。 –

0

はデフォルトでそこに着くなりますので、あなたはから「サイモン」を取得するためにindexAction

$profileName = ltrim($this->getRequest()->getRequestUri(), "/"); 

を使用することができ、あなたのデフォルトのコントローラでありますurl。

関連する問題