holala
(Holala)
1
$file=dirname(__FILE__).DIRECTORY_SEPARATOR.'sexylightbox.v2.3.jquery.min.js';
$jsFile=Yii::app()->getAssetManager()->publish($file);
$cs->registerScriptFile($jsFile);
$imgDir=dirname(__FILE__).DIRECTORY_SEPARATOR.'sexyimages';
Yii::app()->getAssetManager()->publish($imgDir);
but in the assets directory, there have two directorys,one is js file in it,the other is the directory in it,why they not in same directory?
how can i publsh them in same directory.
Please help!
jerry2801
(Jerry2801)
2
you can set the js and images to the same folder,
and then publissh the folder~
like:
xyzFolder/sexylightbox.v2.3.jquery.min.js
xyzFolder/sexyimages/abc.jpg
xyzFolder/sexyimages/def.jpg
$folder=dirname(FILE).DIRECTORY_SEPARATOR.‘xyzFolder’;
$baseUrl=Yii::app()->getAssetManager()->publish($folder);
Raghuraman
(Raghuraman439)
4
Can you please provide some example code here.
I have css files and images folder like this.
<?php
$cs = Yii::app()->getClientScript();
$file1 = dirname(__FILE__).DIRECTORY_SEPARATOR.'/../css/960.css';
$file2 = dirname(__FILE__).DIRECTORY_SEPARATOR.'/../css/example.css';
$file3 = dirname(__FILE__).DIRECTORY_SEPARATOR.'/../css/main.css';
$file4 = dirname(__FILE__).DIRECTORY_SEPARATOR.'/../css/page.css';
$file5 = dirname(__FILE__).DIRECTORY_SEPARATOR.'/../css/reset.css';
$file6 = dirname(__FILE__).DIRECTORY_SEPARATOR.'/../css/slideshows.css';
$file7 = dirname(__FILE__).DIRECTORY_SEPARATOR.'/../css/text.css';
$file8 = dirname(__FILE__).DIRECTORY_SEPARATOR.'/../js/jquery.cycle.all.js';
$file9 = dirname(__FILE__).DIRECTORY_SEPARATOR.'/../js/jquery.easing.1.3.js';
$file10 = dirname(__FILE__).DIRECTORY_SEPARATOR.'/../js/jquery.js';
$file11 = dirname(__FILE__).DIRECTORY_SEPARATOR.'/../js/tabber.js';
$file12 = dirname(__FILE__).DIRECTORY_SEPARATOR.'/../js/jquery-1.10.2.min.js';
$url1 = Yii::app()->getAssetManager()->publish($file1);
$url2 = Yii::app()->getAssetManager()->publish($file2);
$url3 = Yii::app()->getAssetManager()->publish($file3);
$url4 = Yii::app()->getAssetManager()->publish($file4);
$url5 = Yii::app()->getAssetManager()->publish($file5);
$url6 = Yii::app()->getAssetManager()->publish($file6);
$url7 = Yii::app()->getAssetManager()->publish($file7);
$url8 = Yii::app()->getAssetManager()->publish($file8);
$url9 = Yii::app()->getAssetManager()->publish($file9);
$url10 = Yii::app()->getAssetManager()->publish($file10);
$url11 = Yii::app()->getAssetManager()->publish($file11);
$url12 = Yii::app()->getAssetManager()->publish($file12);
$img_dir = dirname(__FILE__).DIRECTORY_SEPARATOR.'/../images/';
Yii::app()->getAssetManager()->publish($img_dir);
$cs->registerCssFile($url1);
$cs->registerCssFile($url2);
$cs->registerCssFile($url3);
$cs->registerCssFile($url4);
$cs->registerCssFile($url5);
$cs->registerCssFile($url6);
$cs->registerCssFile($url7);
$cs->registerScriptFile($url8);
$cs->registerScriptFile($url9);
$cs->registerScriptFile($url10);
$cs->registerScriptFile($url11);
$cs->registerScriptFile($url12);
?>
I need some help guys…
zaccaria
(Matteo Falsitta)
5
Just place the css and js folder in the public folder, at the same level of index.php, and then you can include without publishing.
Raghuraman
(Raghuraman439)
6
Already it is in that structure…
I have loaded some images in the main.css file, by publishing the the css file and the images folder, how to get and display the image…
It says failed to load the given url…
zaccaria
(Matteo Falsitta)
7
So just register the files:
Yii::app()->getClientScript()->registerCssFile(Yii::app()->baseUrl.'/css/960.css');
Raghuraman
(Raghuraman439)
8
I tried the method as you told, but i can’t publish the css. Now the images and the css are loading, But now i need to apply an image as background.
This is the problem i have now…
in main css file an image is loaded…
.top_bg
{
background:url(../images/top_bg.jpg) repeat-x right;
padding: 6px 0px;
}
And i seperately published images and css files.
How to load the images from assests to display in page.