Hi guys,
I want to use a jQuery plugin („Slides“) in my SS theme for a rotating banner.
For this purpose, I have added a text field named “HeaderImages” to the CMS. In this field I would like to write the urls of the images that should be used in the banner of the current site (e.g. ‘image1.jpg’, ‘image2.jpg’, ‘image3.jpg’). The content of this field should be passed to the array of the Slides plugin.
Unfortunately, I couldn’t find out yet how to do that?! I hope someone can help me...
Here’s the code:
Page.php:
class Page extends SiteTree {
public static $db = array(
'HeaderImages' => 'Text'
);
...
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Content.Main', new TextField('HeaderImages'), 'Content');
return $fields;
}
}
class Page_Controller extends ContentController {
...
public function init() {
Requirements::customScript("
jQuery(document).ready(function(){
jQuery('#slideimage').Slides({ images: [image1.jpg, image2.jpg, image3.jpg] });
});
");
parent::init();
}
}
Page.ss:
...
<body>
...
<div id="Header">
<img src="image1.jpg" id="slideimage">
</div>
...
<script type="text/javascript" src="mysite/javascript/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="mysite/javascript/jquery.slides.min.js"></script>
</body>
</html>