CakePHP – 包含基于特定页面的CSS?

我想要包含一个应该应用于主页的特定css文件,以及整个网站中的6-7个其他页面.

我知道我可以通过PHP,获取URL,找到什么页面,链接css等等来做到这一点,但我想知道是否有一个光滑的方式(或任何更好的方式)使用CakePHP包含正确的CSS文件(S).

我意识到我可以从特定的视图链接CSS文件,但是 – 然后它们不会在< head>中.有没有办法从视图中链接并将其显示在头部?

我希望我的问题有意义,并且非常感谢任何帮助.

I realize I can link the CSS file from
the specific views,but – then they
wouldn’t be in the <head>. Is there a
way to link from a view and have it
show up in the head?

是的,他们会在头脑中.见HTML Helper documentation

If key ‘inline’ is set to false in
$options parameter,the link tags are
added to the $scripts_for_layout
variable which you can print inside
the head tag of the document.

那么,你的视图中的这个片段……

$this->Html->css('my-css',null,array('inline' => false));

…将添加正确的< link>元素到你的< head>.

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...