từ khóa và mô tả tạo không có bộ điều khiển/hành động
đăng ký 2 plugin trong bootstrap
// register navigation, $view->navigation()->setContainer(new Zend_Navigation($navigationArray));
$controller = Zend_Controller_Front::getInstance();
$controller->registerPlugin(new App_Controller_Plugin_PrepareNavigation());
$controller->registerPlugin(new App_Controller_Plugin_SetMeta());
Plugin Meta có thể trông giống như:
public function routeShutdown(Zend_Controller_Request_Abstract $request)
{
$view = Zend_Controller_Action_HelperBroker::getExistingHelper('ViewRenderer')->view;
$activePage = $view->navigation()->findOneBy('active', true);
$view->headTitle($activePage->title);
$view->headMeta()->appendName('keywords', $activePage->keywords);
$view->headMeta()->appendName('description', $activePage->description);
$view->pageHeader = $activePage->pageHeader;
}
navigationArray sẽ hơn:
'pages' => array(
array('label' => 'introduction',
'controller' => 'controller',
'action' => 'introduction',
'route' => 'controlleraction',
'pageHeader' => 'h1 or something',
'title' => 'used as meta title'
'keywords' => 'meta keywords'
'description' => 'meta desc',
hơn bạn có thể gọi đơn giản (từ bố cục/view) print $ this-> pageHeader;
Tôi đã thử làm điều đó nhưng sau đó nó trả về lỗi: Lỗi nghiêm trọng: Ngoại lệ không được phép 'Zend_Application_Bootstrap_Exception' với thông báo 'Kết hợp tài nguyên' xem "không tìm thấy 'và khi tôi thêm resources.view [] =" "vào application.ini, trợ giúp xem của tôi đột nhiên ngừng hoạt động –
Bạn khởi động như thế nào? Có khác gì ở zend chính thức [hướng dẫn bắt đầu nhanh] (http://framework.zend.com/manual/en/learning.quickstart.create-layout.html) không? – Marcin