2011-08-17 29 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(); 
相關問題