给Zend Framework设置网站图标

正规的方法应该类似下面这样:


//application/Bootstrap.php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected function _initView()
{
// Initialize view
$view = new Zend_View();
$view->doctype('XHTML1_STRICT');
$view->headLink()->headLink( array( 'rel' => 'favicon',
'href' => $view->baseUrl( 'favicon.ico' ),
'type' => 'image/x-icon' ));
// 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;
}
}

然后在布局文件的头部加入下面的代码( application/layouts/scripts/layout.phtml ):

<?php echo $this->headLink()?>

可能还有更优雅的方法,待

Chinese, Simplified(简体中文)

添加新评论