<?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>Mister McIntosh Says &#187; Flickr</title>
	<atom:link href="http://mistermcintoshsays.org/tag/flickr/feed/" rel="self" type="application/rss+xml" />
	<link>http://mistermcintoshsays.org</link>
	<description>&#34;Happiness lies in the joy of achievement and the thrill of creative effort.&#34; ~ Franklin D. Roosevelt</description>
	<lastBuildDate>Tue, 24 Jan 2012 00:27:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>How to Display Random Banners at the Top of a Moodle Page</title>
		<link>http://mistermcintoshsays.org/2011/05/22/how-to-display-random-banners-at-the-top-of-a-moodle-page/</link>
		<comments>http://mistermcintoshsays.org/2011/05/22/how-to-display-random-banners-at-the-top-of-a-moodle-page/#comments</comments>
		<pubDate>Mon, 23 May 2011 03:23:03 +0000</pubDate>
		<dc:creator>Mister McIntosh</dc:creator>
				<category><![CDATA[21st Century Skills]]></category>
		<category><![CDATA[Demonstration]]></category>
		<category><![CDATA[Info]]></category>
		<category><![CDATA[Mathematics]]></category>
		<category><![CDATA[Topic Talk]]></category>
		<category><![CDATA[Flickr]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Moodle]]></category>
		<category><![CDATA[Moodle graphics]]></category>
		<category><![CDATA[rotating banners]]></category>

		<guid isPermaLink="false">http://mistermcintoshsays.org/?p=750</guid>
		<description><![CDATA[It is fun to customize a Moodle page to make it &#8220;your own.&#8221; One way to do this is to put an interesting image at the top of a course page. That looks something like this: I got to thinking, wouldn&#8217;t it be cool if I could show a random banner graphic each time the [...]]]></description>
			<content:encoded><![CDATA[<p>It is fun to customize a Moodle page to make it &#8220;your own.&#8221; One way to do this is to put an interesting image at the top of a course page. That looks something like this:</p>
<p style="text-align: left;">
<div id="attachment_761" class="wp-caption aligncenter" style="width: 462px"><a href="http://mistermcintoshsays.org/files/2011/05/MoodleHeader-ue4onj.jpg"><img class="size-large wp-image-761   " title="MoodleHeader" src="http://mistermcintoshsays.org/files/2011/05/MoodleHeader-ue4onj-1024x525.jpg" alt="Banner Graphic at Top of a Moodle Page" width="452" height="232" /></a><p class="wp-caption-text">Banner Graphic at Top of a Moodle Page</p></div>
<p>I got to thinking, <em>wouldn&#8217;t it be cool if I could show a random banner graphic each time the page loaded?</em> Yes. Yes it would.</p>
<p style="text-align: left;">After snooping around the Moodle forums, searching the internet for examples of how to do it, and looking at some books, I found a way to use a relatively simple JavaScript to do the job.</p>
<p style="text-align: center;"><strong>A JavaScript Banner Rotator in Moodle</strong></p>
<p style="text-align: left;">Here is how you do it:</p>
<p style="text-align: left;">(1) First you have to get yourself some graphics. Images with pixel dimensions of about 125  x 530 fit pretty well, but you&#8217;ll see a way to scale all your images to the same size is included in the JavaScript if you need it. I have included 3 banners at the end of this post you can use to try it. They were made by using creative commons images found on Flickr.</p>
<p style="text-align: left;">(2) Put all you banners in a folder called &#8220;Banners&#8221; or something equally descriptive and compress the folder into a zip archive.</p>
<p style="text-align: left;">(3) Upload the zipped Banners folder to your Moodle files repository and unzip it.</p>
<p style="text-align: left;">(4) On your Moodle course page, turn editing on and click on the edit link (the little paper and pencil icon) for the top section of your Moodle page. There is probably some text in that space at the moment. You can keep the text and add the images below it or you can forgo the text all together and replace it with your randomly rotating banners.</p>
<p style="text-align: left;">(5) When the section opens for editing, enter html editing mode by clicking on the angle bracket icon (&lt;&gt;) on the tool bar. With or without keeping whatever text is already there, copy and past the following code into the editing window:</p>
<p style="text-align: left; padding-left: 30px;">&lt;head&gt;</p>
<p style="text-align: left; padding-left: 30px;">&lt;script language=&#8221;JavaScript&#8221;&gt;</p>
<p style="padding-left: 30px;">function bannerRotate()</p>
<p style="padding-left: 30px;">{</p>
<p style="padding-left: 30px;">var bannerArray = new Array();</p>
<p style="text-align: left; padding-left: 30px;">/*specify the urls of the images below. Replace these fake urls by opening your Banners folder in Moodle to copy and paste the complete correct path to each image for each banner*/</p>
<p style="text-align: left; padding-left: 30px;">bannerArray[0]=&#8221;http://moodlepath&#8230;/examplebanner1.jpg&#8221;;<br />
bannerArray[1]=&#8221;http://moodlepath&#8230;/examplebanner2.jpg&#8221;;<br />
bannerArray[2]=&#8221;http://moodlepath&#8230;/examplebanner3.jpg&#8221;;</p>
<p style="padding-left: 30px;">/*Put in links to where you got your legally obtained banners in the following array. If you make your own banners you don&#8217;t need to do that and you can comment out the array index statements, but you must leave the new Array () creation statement intact*/</p>
<p style="text-align: left; padding-left: 30px;">var creditLinks=new Array()</p>
<p style="padding-left: 30px;">creditLinks[0]=&#8221;http://www.bannersource1.com&#8221;;<br />
creditLinks[1]=&#8221;http://www.bannersource2.com&#8221;;<br />
creditLinks[2]=&#8221;http://www.bannersource3.com&#8221;;</p>
<p style="padding-left: 30px;">var n = Math.floor(Math.random()*bannerArray.length);</p>
<p style="padding-left: 30px;">document.write(&#8216;&lt;a href=&#8217;+'&#8221;&#8216;+creditLinks[n]+&#8217;&#8221;&#8216;+&#8217;&gt;&lt;img src=&#8221;&#8216;+bannerArray[n]+&#8217;&#8221; border=0 height=130 width=550&gt;&lt;/a&gt;&#8217;);</p>
<p style="padding-left: 30px;">}</p>
<p style="padding-left: 30px;">bannerRotate();</p>
<p style="padding-left: 30px;">&lt;/script&gt;</p>
<p style="padding-left: 30px;">&lt;/head&gt;</p>
<p>(6) Save your edits and return to your Moodle page. You should see the banner appear and a random one from the array will be displayed each time the page is loaded.</p>
<p>If all your banners are the same size and the right size to keep the page from looking all wonky you don&#8217;t need the height=130 width=550 attributes in the document.write statement. But, by using those attributes and changing them as needed, you can make any reasonably sized banners fit in the allotted space.</p>
<p>WARNING! When you return to the html view of that section, the code will not look the same as it did when you put it there. Moodle strips out some things and modifies the code in accordance with its own designs. It will also probably stop working if you try to edit it in any way. So, keep a clean copy of the above JavaScript (with all the correct links for your installation) in a text document somewhere and use only that document to experiment, add more images, etc. and then delete the code in Moodle and start fresh each time.</p>
<p>I currently run 12 rotating banners on my algebra and pre-algebra pages and they are working fine. Please let me know how it works for you. Three images for you to use are included below. I made them by using PhotoShop to crop creative commons licensed images found on flickr.com. If you use them, please credit them to the Flickr pages from whence they came (follow the image links).</p>
<p><a href="http://www.flickr.com/photos/pathfinderlinden/5345271930/"><img class="aligncenter size-full wp-image-747" title="examplebanner1" src="http://mistermcintoshsays.org/files/2011/05/examplebanner1-1t0qp02.jpg" alt="examplebanner1" width="512" height="97" /></a></p>
<p><a href="http://www.flickr.com/photos/robert_scarth/401067121/" target="_blank"><img class="aligncenter size-full wp-image-748" title="examplebanner2" src="http://mistermcintoshsays.org/files/2011/05/examplebanner2-2alrgyh.jpg" alt="examplebanner2" width="508" height="99" /></a></p>
<p><a href="http://www.flickr.com/photos/siriwan/5432138720/" target="_blank"><img class="aligncenter size-full wp-image-749" title="examplebanner3" src="http://mistermcintoshsays.org/files/2011/05/examplebanner3-2dmea4a.jpg" alt="examplebanner3" width="500" height="114" /></a></p>
<p style="text-align: center;"><strong>References</strong></p>
<p>Anonymous, <em>JavaScript in Easy Steps</em>, Computer Step, Warwickshire, UK: 2003</p>
<p>Anonymous, &#8220;<a href="http://www.java-scripts.net/javascripts/Random-Image-Script.phtml" target="_blank">Random Image Script JavaScript</a>&#8220;, &lt;http://www.java-scripts.net/javascripts/Random-Image-Script.phtml&gt;, Accessed May 20, 2011</p>
]]></content:encoded>
			<wfw:commentRss>http://mistermcintoshsays.org/2011/05/22/how-to-display-random-banners-at-the-top-of-a-moodle-page/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
