2011-08-17 67 views
3

在我的Zend Framework的应用程序,我想与之呼应的doctype我认为布局:如何呼应的doctype,在设定的application.ini,Zend框架视图

<?= $this->doctype() . "\n"; ?> 

我在我的应用程序下面的行的.ini:

resources.view[] = 
resources.view.doctype = "HTML5" 
resources.view.charset = "UTF-8" 

这给了我:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 

显然中的application.ini设置igno红色,而是使用默认的文档类型。

有没有办法在我的视图/布局中使用doctype而不使用引导程序(我知道这可行,但我不想让我的设置分散在application.ini和bootstrap上)?

+0

是否需要行`resources.view [] =`?我不知道这是否会导致问题? – ChrisA 2011-08-17 10:31:51

+0

@ChrisAnstey不,我不需要它,删除它,但它不会导致问题 – tihe 2011-11-17 20:02:07

回答

3

您需要配置在bootstrap.php中

protected function _initView() 
{ 
    // Initialize view 
    $view = new Zend_View(); 
    $view->doctype('XHTML1_TRANSITIONAL'); 
    $view->setEncoding('UTF-8');//per , htmlentities($str, ENT_QUOTES, "UTF-8"); 

    $view->headTitle('ABC'); 


    // Add it to the ViewRenderer 
    $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer'); 
    $viewRenderer->setView($view); 
    // Return it, so that it can be stored by the bootstrap 
    return $view; 
} 

然后在布局或一些人认为使用您的视图

echo $this->doctype();