我在zend控制器中附加了一些样式表但是显示了空白页面,我如何在zend控制器中包含样式表和javascript文件?这是我的代码:
public function showAction()
{
//css
$this->viewHelperManager->get('headLink')->appendStylesheet('/css/style.css');
$this->viewHelperManager->get('headLink')->appendStylesheet('/css/bootstrap-theme.min.css');
$this->viewHelperManager->get('headLink')->appendStylesheet('/css/tweaks.css');
$this->viewHelperManager->get('headLink')->appendStylesheet('/css/fullcalendar.css');
$this->viewHelperManager->get('headLink')->appendStylesheet('/css/fullcalendar.print.css');
$this->viewHelperManager->get('headLink')->appendStylesheet('/css/jquery-ui.min.css');
$this->viewHelperManager->get('headLink')->appendStylesheet('/css/jquery.simple-dtpicker.css');
//js
$this->viewHelperManager->get('headScript')->appendFile('/admin_static/js/jquery-ui-1.10.3.custom/js/jquery-ui-1.10.3.custom.min.js');
$id = (int) $this->params()->fromRoute('id', 0);
if (!$id) {
return $this->redirect()->toRoute('calendar', array(
'action' => 'create'
));
}
$calendar = $id;
$dm = $this->getServiceLocator()->get('doctrine.documentmanager.odm_default');
$eventshow = $dm->createQueryBuilder('Calendar\Document\Calendar')
->hydrate(false)
->field("id")->equals($id)
->getQuery()->execute();
$array = array();
if($eventshow && !is_null($eventshow) && is_object($eventshow)){
foreach($eventshow as $key=>$value) {
$array[] = array(
'calendar_id' => $value['_id'],
'user_id' => $value['user_id'],
'title' => $value['title'],
'description' => $value['description'],
);
}
}
return array('calendar' => $calendar , 'calendardata' => $array);
}
答案 0 :(得分:1)
'空白页'只是表示正在生成错误,但您已关闭display_errors
。检查您的Web服务器错误日志以查看实际问题(这将有助于您调试未来的问题)。
通过查看您的代码,我猜测问题出在$this->viewHelperManager
的调用上,因为没有这样的事情(除非您在控制器的其他地方设置了它)。 / p>
你可能想要:
$this->getServiceLocator()->get('viewhelpermanager')->get('headLink')->appendStylesheet('/css/style.css');
虽然如果你需要那么多的视图助手调用,可能值得将headLink助手作为依赖项传递。