Reputation: 14707
I am trying to implement Supersized slider with my Yii project. In order to implement I have to implement some javascript in the view. So I decided to go with the registerscript method. But I think I am not able to initialized the directory location of the images. Could you help me
My code is
<?php
$script= <<<EOD
jQuery(function($){
$.supersized({
slide_interval :7000, // Length between transitions
transition :1, // 0-None, 1-Fade, 2-Slide Top, 3-Slide Right, 4-Slide Bottom, 5-Slide Left, 6-Carousel Right, 7-Carousel Left
transition_speed :1000, // Speed of transition
slide_links :'blank',// Individual links for each slide (Options: false, 'num', 'name', 'blank')
slides :[// Slideshow Images
$directory = Yii::getPathOfAlias('webroot').'/uploads/';
$images = glob($directory . "*.{jpg,JPG,jpeg,JPEG,png,PNG}", GLOB_BRACE);
foreach($images as $image)
echo "{image : 'http://localhost/uploads/" . $image . "', title : '" .$image . "'},";
]
});
});
EOD;
Yii::app()->clientScript->registerScript('customFnc', $script, CClientScript::POS_READY);?>
Upvotes: 0
Views: 133
Reputation: 223
Try This Way..
<script>
jQuery(function($){
$.supersized({
slide_interval :7000, // Length between transitions
transition :1, // 0-None, 1-Fade, 2-Slide Top, 3-Slide Right, 4-Slide Bottom, 5-Slide Left, 6-Carousel Right, 7-Carousel Left
transition_speed :1000, // Speed of transition
slide_links :'blank',// Individual links for each slide (Options: false, 'num', 'name', 'blank')
slides :[// Slideshow Images
<?php
$directory = Yii::getPathOfAlias('webroot').'/uploads/';
$images = glob($directory . "*.{jpg,JPG,jpeg,JPEG,png,PNG}", GLOB_BRACE);
foreach($images as $image)
echo "{image : 'http://localhost/uploads/" . $image . "', title : '" .$image . "'},"; ?>
]
});
});
</script>
Upvotes: 2