CakePHP-如何将HTML CSS Helper链接到其他文件夹 [英] CakePHP - how to link html css helper to a different folder

查看:62
本文介绍了CakePHP-如何将HTML CSS Helper链接到其他文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前,我正在使用它来加载CakePHP项目中的CSS。

Currently I'm using using this to load in css in my CakePHP project.

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

这是假定我将css文件放在css文件夹中。

但是,我现在正在考虑将js库所需的css移到js文件夹中。 (即js / lib / jquery-ui.js和js / lib / jquery-ui.css中)。这样,我不必跟踪2个结构相同的文件夹。

That is assuming that I'm putting my css file in a css folder.
However, I'm now thinking about moving my css that is needed for js libraries to the js folder instead. (i.e in js/lib/jquery-ui.js AND js/lib/jquery-ui.css). That way I don't have to keep track of 2 folders with the same structure.

如何更改CakePHP的css助手指向不同文件夹的位置?

或这不是我要尝试的好习惯。 (例如,将插件css移到与js相同的文件夹中)

How can I change where CakePHP's css helper to point to a different folder?
Or is that not a good practice what I'm trying to do. (i.e moving the plugin css to live in the same folder as the js)

谢谢,

Tee

Thanks,
Tee

推荐答案

来自 API


如果 $ path 带有前缀'/',该路径将相对于您应用程序的webroot。否则,该路径将相对于您的CSS路径

If $path is prefixed with '/', the path will be relative to the webroot of your application. Otherwise, the path will be relative to your CSS path

所以您应该这样做:

echo $this->Html->css('/js/lib/jquery-ui',null,array('inline' => false));

这篇关于CakePHP-如何将HTML CSS Helper链接到其他文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆