2011-08-01 6 views
0

내 앱에 프로필 이름 (예 : www.mydomain.com/simon)이 ​​필요하면 simon은 컨트롤러가 아니며 프로필을 가져 오는 사용자의 사용자 이름은 가능합니까?컨트롤러를로드하지 않고도 앱에 액세스 할 수 있습니까?

class ProfileController extends Zend_Controller_Action { 


    public function init() { 

    } 

    public function indexAction(){ 

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

여기가 사용자를 표시 할 수있는 곳입니다. 당신은 기본적으로 거기에 도착 있도록 ProfileController을 가정하면

} 

또는 뭔가

...

답변

3

이 목적으로 Zend_Route을 사용할 수 있습니다.

그냥 응용 프로그램 부트 스트랩에 다음을 추가

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') 
    )); 
} 

더 많은 정보를 Zend_Controller_Routerhere를 사용하여.

+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.

관련 문제