我需要创建一个javascript变量,其中包含webroot中css文件夹的路径,用于引用css的jQuery WYSIWYG插件。
我的代码放在布局文件的头部
echo $this->Html->scriptBlock(sprintf('var WEBROOT_PATH = "%s";', WWW_ROOT));
bootstrap3-wysihtml5.js
var defaultOptions = $.fn.wysihtml5.defaultOptions = {
"link": true,
"image": true,
"size": 'sm',
events: {},
parserRules: {
classes: {
"wysiwyg-color-silver" : 1,
},
tags: {
"b": {},
"i": {},
"blockquote": {},
"u": 1,
"img": {
"check_attributes": {
"width": "numbers",
"alt": "alt",
"src": "url",
"height": "numbers"
}
},
"span": 1,
}
},
stylesheets: [WEBROOT_PATH+"css/bootstrap3-wysiwyg5-color.css"],
locale: "en"
};
我已经尝试了所有的cakephp常量,它们都导致绝对路径
http://localhost:8888/Users/keithpower/Documents/Website%20Projects/btstadmin/app/webroot/css/bootstrap3-wysiwyg5-color.css
我需要的路径是
http://localhost:8888/btstadmin/app/webroot/css/bootstrap3-wysiwyg5-color.css
我也试过
stylesheets: ["/css/bootstrap3-wysiwyg5-color.css"],
我得到了
http://localhost:8888/css/bootstrap3-wysiwyg5-color.css