微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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>.

原文地址:https://www.jb51.cc/php/135756.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐