2014-10-03 5 views
0

У меня есть такой код, но он не worfingКак добавить маршрут к такому URL/индекс/ViewModel/ID/{ID}/в Zend Framework

$route = new Zend_Controller_Router_Route_Static ('viewmodel', array (
    'controller' => 'Index', 
    'action' => 'viewmodel' 
)); 
$router->addRoute('viewmodel', $route); 

PS: Рабочий код

$routerTwo = Zend_Controller_Front::getInstance()->getRouter(); 
     $route = new Zend_Controller_Router_Route(':index/:viewmodel/:id', array (
      'controller' => 'index', 
      'action' => 'viewmodel' 
     )); 
     $routerTwo->addRoute('viewmodel', $route); 
+0

эй! Маршрут Zend Framework по умолчанию должен сделать трюк для вас! –

ответ

0

Попробуйте что

$route = new Zend_Controller_Router_Route('index/viewmodel/id/:id', array (
    'controller' => 'index', 
    'action' => 'viewmodel' 
)); 
$router->addRoute('viewmodel', $route); 

В акции вы можете получить доступ: идентификатор по $this->getRequest()->getParam('id');

+0

Это не поможет. «Страница не найдена» –

+0

С ее помощью: $ routerTwo = Zend_Controller_Front :: getInstance() -> getRouter(); $ route = new Zend_Controller_Router_Route (': index /: viewmodel /: id', array ( 'controller' => 'index', 'action' => 'viewmodel' )); $ routerTwo-> addRoute ('viewmodel', $ route); –

Смежные вопросы