기본/모듈/컨트롤러/동작/값 라우팅 구조를 유지하면서 허영 URL "캐치 올"경로를 만들 수 있습니까?Zend 프레임 워크에서 가상 URL (예 : http://facebook.com/JohnDoe)을 구현하고 있습니까?
감사합니다.
기본/모듈/컨트롤러/동작/값 라우팅 구조를 유지하면서 허영 URL "캐치 올"경로를 만들 수 있습니까?Zend 프레임 워크에서 가상 URL (예 : http://facebook.com/JohnDoe)을 구현하고 있습니까?
감사합니다.
프런트 컨트롤러 플러그인에서 PreDispatch() 훅을 사용할 수 있습니다. 그래서 같이 :
<?php
...
$frontController = Zend_Controller_Front::getInstance();
// Set our Front Controller Plugin
$frontController->registerPlugin(new Mystuff_Frontplugin());
?>
그런 mystuff에/Frontplugin.php
<?php
class Mystuff_Frontplugin extends Zend_Controller_Plugin_Abstract
{
....
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
....
$controllerFile = $this->_GetRequestedControllerFile();
if (!is_file($controllerFile)) {
// Controller does not exist
// re-route to another location
$request->setModuleName('customHandler');
$request->setControllerName('index');
$request->setActionName('index');
}
}
....
}
또한 preDispatch()는 응용 프로그램 전체 인증을 처리 할 수있는 편리한 위치입니다 내부 부트 스트랩에서
.
그것은 더 나은 부트 스트랩 예를 들면 사용자 설정 사용자 지정 경로의 경우 :
protected function _initRoutes() {
$this->bootstrap('frontController');
$front = $this->getResource('frontController');
$router = $front->getRouter();
$router->addRoute(
'neat_url',
new Zend_Controller_Router_Route(
'profile/:username',
array(
'controller' => 'profiles',
'action' => 'view_profile'
)
)
);
}
여전히 기본 경로가 있고/프로필/jhon에서 모든 리디렉션됩니다 사용자 정의 경로를 가질 수 이쪽으로. 그러면 컨트롤러 아래에서 $ this -> _ getParam ('username');을 사용하여 매개 변수를 가져옵니다.
감사합니다. 랜스! 어디에서 플러그인 디렉토리를 설정합니까? application.ini 파일과 함께 Zend_Application을 사용 중입니다. 치명적인 오류 : 'ControllerPlugins_Vanityurl'클래스가 C : \ ***** \ library \ Zend \ Application \ Resource \ Frontcontroller.php의 90 행에 없습니다. (라이브러리 폴더에 ControllerPlugins 디렉터리가 있습니다. 감사합니다. – arendn
감사합니다. 랜스 지금 작업하고 있습니다 :-) – arendn