<?xml version="1.0" encoding="UTF-8"?> <rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
> <channel><title>Erhan is typing... &#187; SilverStripe</title> <atom:link href="http://www.erhanabay.com/category/silverstripe/feed/" rel="self" type="application/rss+xml" /><link>http://www.erhanabay.com</link> <description>WebDevelopment , PHP, Javascript, CakePHP, ExtJS</description> <lastBuildDate>Wed, 11 Jan 2012 13:04:15 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <item><title>Image Rotator For Your SilverStripe Application</title><link>http://www.erhanabay.com/2009/01/30/image-rotator-for-your-silverstripe-application/</link> <comments>http://www.erhanabay.com/2009/01/30/image-rotator-for-your-silverstripe-application/#comments</comments> <pubDate>Fri, 30 Jan 2009 00:15:43 +0000</pubDate> <dc:creator>Erhan Abay</dc:creator> <category><![CDATA[PHP]]></category> <category><![CDATA[SilverStripe]]></category> <category><![CDATA[image rotator]]></category> <category><![CDATA[widget]]></category> <guid
isPermaLink="false">http://erhanabay.com/?p=195</guid> <description><![CDATA[I used SilverStripe to develop couple of projects and I really liked it. I am still a fan of CakePHP but you should give a try if you don&#8217;t want to build a new CMS from scratch with CakePHP. I want to show you how easy to add an image rotator to your SilverStripe site [...]]]></description> <content:encoded><![CDATA[<p>I used <a
href="http://www.silverstripe.org" onclick="pageTracker._trackPageview('/outgoing/www.silverstripe.org?referer=');">SilverStripe</a> to develop couple of projects and I really liked it. I am still a fan of <a
href="http://cakephp.org" onclick="pageTracker._trackPageview('/outgoing/cakephp.org?referer=');">CakePHP</a> but you should give a try if you don&#8217;t want to build a new CMS from scratch with CakePHP.</p><p>I want to show you how easy to add an image rotator to your SilverStripe site by using <a
href="http://www.longtailvideo.com/players/jw-image-rotator/" onclick="pageTracker._trackPageview('/outgoing/www.longtailvideo.com/players/jw-image-rotator/?referer=');">JW Image Rotator</a>. You can see it in action at <a
href="http://sumpa.com.tr/" onclick="pageTracker._trackPageview('/outgoing/sumpa.com.tr/?referer=');">sumpa.com.tr</a>.</p><p>First <a
href="http://www.longtailvideo.com/players/jw-image-rotator/" onclick="pageTracker._trackPageview('/outgoing/www.longtailvideo.com/players/jw-image-rotator/?referer=');">download</a> the greatest flash image rotator, JW Image Rotator. Then copy/move it to your SilverStripe project folder. I prefer &#8220;images&#8221; folder.</p><p><img
class="size-full wp-image-198 aligncenter" title="ss01" src="http://erhanabay.com/wp-content/uploads/2009/01/ss01.png" alt="ss01" width="229" height="576" /></p><p>In order to add or remove new images (or swf files) to your rotator easily, we are going to use a folder in our &#8220;Uploads&#8221; directory and list all the files in this folder. Let&#8217;s assume that our directory name is &#8220;flash&#8221;. To do that, go to your admin panel in SilverStripe, switch to &#8220;Files &amp; Images&#8221; tab in your menu and create a new directory called &#8220;flash&#8221;.</p><p><a
href="http://erhanabay.com/wp-content/uploads/2009/01/ss02.png" onclick="pageTracker._trackPageview('/outgoing/erhanabay.com/wp-content/uploads/2009/01/ss02.png?referer=');"><img
class="aligncenter size-full wp-image-199" title="ss02" src="http://erhanabay.com/wp-content/uploads/2009/01/ss02.png" alt="ss02" width="332" height="254" /></a></p><p>In your Page class, define a new method called ImageRotator().</p><pre class="brush: php; title: ; notranslate">
// myproject/code/Page.php
class Page extends SiteTree {
  static $db = array();
  static $has_one = array();
  function ImageRotator() {
    return DataObject::get('File', 'ClassName &lt;&gt; &quot;Folder&quot; AND ParentID = (SELECT ID FROM File WHERE ClassName = &quot;Folder&quot; AND Name = &quot;flash&quot; LIMIT 0,1)');
  }
}
</pre><p>Create a new file &#8220;ImageRotator.ss&#8221; in &#8220;myproject/templates/&#8221;</p><pre class="brush: xml; title: ; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;playlist version=&quot;1&quot; xmlns=&quot;http://xspf.org/ns/0/&quot;&gt;
  &lt;trackList&gt;
  &lt;% if ImageRotator %&gt;
    &lt;% control ImageRotator %&gt;
    &lt;track&gt;
      &lt;title&gt;$Title.XML&lt;/title&gt;
      &lt;location&gt;$BaseHref$Filename.XML&lt;/location&gt;
    &lt;/track&gt;
    &lt;% end_if %&gt;
  &lt;% end_control %&gt;
  &lt;/trackList&gt;
&lt;/playlist&gt;
</pre><p> </p><p>Create a new file &#8220;Flash.ss&#8221; in &#8220;myproject/templates/Includes&#8221;</p><pre class="brush: xml; title: ; notranslate">
&lt;!--
Don't change the &quot;file&quot; variable. This is the URI of our XML which contains images
You can change other settings or add/remove.
--&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
var introFlashvars = {
  width: &quot;950&quot;,
  height: &quot;300&quot;,
  file: &quot;$URLSegment/ImageRotatorXML&quot;,
  shownavigation: false,
  screencolor: &quot;0xFFFFFF&quot;,
  rotatetime: 15
};
var params = {
  wmode: &quot;transparent&quot;
}
&lt;/script&gt;
&lt;!--
Following div with id &quot;Intro&quot; is used as a container for our image rotator.
Browsers which are not supporting Javascript, &quot;dummyimage.jpg&quot; image linked to the home page is displayed
Don't forget to add swfobject.js into your head tag!
You can download it from http://code.google.com/p/swfobject/
--&gt;
&lt;div id=&quot;Intro&quot;&gt;&lt;a href=&quot;/&quot;&gt;&lt;img src=&quot;dummyimage.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
  swfobject.embedSWF(&quot;$ThemeDir/images/imagerotator.swf&quot;, &quot;Intro&quot;, introFlashvars.width, introFlashvars.height, &quot;8&quot;, false, introFlashvars, params);
&lt;/script&gt;
</pre><p>We complete the steps to create our rotator. Now, you can call it from any page that you want with the following include directive:</p><pre class="brush: xml; title: ; notranslate">
&lt;% include Flash %&gt;
</pre><p>Upload your images and swf files into your &#8220;flash&#8221; directory and open the page by adding &#8220;?flush=1&#8243; to URI. It will refresh the cache.</p><p>I know, it should be a widget so that it can easily be added to the pages without hardcoding. I am not planning to do that kind of work but if you find it useful, convert it to a widget and <a
href="http://www.silverstripe.org/widgets/" onclick="pageTracker._trackPageview('/outgoing/www.silverstripe.org/widgets/?referer=');">share with community</a>. You are free to do that! No license, no restrictions&#8230; <img
src='http://www.erhanabay.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p><p>Contributions are welcome&#8230;</p> ]]></content:encoded> <wfw:commentRss>http://www.erhanabay.com/2009/01/30/image-rotator-for-your-silverstripe-application/feed/</wfw:commentRss> <slash:comments>4</slash:comments> </item> </channel> </rss>
