<?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>Dave Cavins &#187; captify</title>
	<atom:link href="http://davecavins.com/tag/captify/feed/" rel="self" type="application/rss+xml" />
	<link>http://davecavins.com</link>
	<description>web design, SharePoint customization &#38; random stuff</description>
	<lastBuildDate>Mon, 14 Jun 2010 18:48:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Displaying a rotating header image with caption</title>
		<link>http://davecavins.com/2010/01/displaying-a-rotating-header-image-with-caption/</link>
		<comments>http://davecavins.com/2010/01/displaying-a-rotating-header-image-with-caption/#comments</comments>
		<pubDate>Thu, 21 Jan 2010 03:20:00 +0000</pubDate>
		<dc:creator>davecavins</dc:creator>
				<category><![CDATA[General SharePoint]]></category>
		<category><![CDATA[SharePoint Design]]></category>
		<category><![CDATA[captify]]></category>
		<category><![CDATA[Data View Web Part]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[slideshow]]></category>

		<guid isPermaLink="false">http://davecavins.com/?p=403</guid>
		<description><![CDATA[Nothing makes a site look good like nice images. Using a large header graphic on you Sharepoint site can help direct users to some important information or announcement. Many non-SharePoint images use this technique to add interest to their site and attract visitors. Doing something like this in SharePoint will make your site a lot [...]


Related posts:<ol><li><a href='http://davecavins.com/2010/04/anything-slider-in-sharepoint-update/' rel='bookmark' title='Permanent Link: Anything Slider in SharePoint &#8211; Update'>Anything Slider in SharePoint &#8211; Update</a></li>
<li><a href='http://davecavins.com/2010/04/switch-list-displays-with-jquery-and-css/' rel='bookmark' title='Permanent Link: Switch List Displays with JQuery and CSS'>Switch List Displays with JQuery and CSS</a></li>
<li><a href='http://davecavins.com/2009/12/css-tricks-anythingslider-in-sharepoint/' rel='bookmark' title='Permanent Link: CSS-Tricks AnythingSlider in SharePoint'>CSS-Tricks AnythingSlider in SharePoint</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Nothing makes a site look good like nice images.  Using a large header graphic on you Sharepoint site can help direct users to some important information or announcement. Many non-SharePoint images use this technique to add interest to their site and attract visitors.  Doing something like this in SharePoint will make your site a lot less &#8216;SharePointy&#8217; (my made up word for sites that look like SharePoint).  Here is how I did it.</p>
<div id="attachment_413" class="wp-caption aligncenter" style="width: 446px"><a href="http://davecavins.com/wp-content/uploads/2010/01/caption.gif"><img class="size-full wp-image-413" title="caption" src="http://davecavins.com/wp-content/uploads/2010/01/caption.gif" alt="" width="436" height="218" /></a><p class="wp-caption-text">Rotating images with captions</p></div>
<p><span id="more-403"></span></p>
<h1>Setup</h1>
<ol>
<li>Create an Image Library to hold your header images,  I named my list &#8216;Headers&#8217;. You can add additional fields to the list if you want but its not necessary for this to work.</li>
<li>Find the images you want to use and re-size them to all be the same dimensions, I used 600px x 200px.</li>
<li>Upload the images to the library and fill in the meta data for each one. Just make sure the &#8216;Title&#8217; field has something in it because that is what we will use for our captions.</li>
</ol>
<h1>The hard part</h1>
<p>Ok really its not hard at all.</p>
<ol>
<li> In SharePoint Designer and add a data view web part to the page.  It does not matter what fields you show in the DVWP the important part is that it is pulling its contents from the Image Library you created.</li>
<li>Switch to &#8216;split view&#8217; and find the  tag. It should be right after the  tag in the code. Right click on the  tag and choose &#8216;Select&#8217; tag. Press delete.
<div id="attachment_408" class="wp-caption aligncenter" style="width: 170px"><a href="http://davecavins.com/wp-content/uploads/2010/01/codeview.jpg"><img class="size-full wp-image-408" title="codeview" src="http://davecavins.com/wp-content/uploads/2010/01/codeview.jpg" alt="" width="160" height="31" /></a><p class="wp-caption-text">Split view</p></div>
<div id="attachment_412" class="wp-caption aligncenter" style="width: 103px"><a href="http://davecavins.com/wp-content/uploads/2010/01/xsl.jpg"><img class="size-full wp-image-412" title="xsl" src="http://davecavins.com/wp-content/uploads/2010/01/xsl.jpg" alt="" width="93" height="71" /></a><p class="wp-caption-text">XSL tag</p></div>
<p><div id="attachment_411" class="wp-caption aligncenter" style="width: 213px"><a href="http://davecavins.com/wp-content/uploads/2010/01/selecttag1.jpg"><img class="size-full wp-image-411" title="selecttag" src="http://davecavins.com/wp-content/uploads/2010/01/selecttag1.jpg" alt="" width="203" height="126" /></a><p class="wp-caption-text">Select Tag</p></div></li>
<li>Paste this code where the  tag used to be.</li>
<pre class="brush: plain;">
&lt;XSL&gt;
&lt;xsl:stylesheet xmlns:x=&quot;http://www.w3.org/2001/XMLSchema&quot; xmlns:d=&quot;http://schemas.microsoft.com/sharepoint/dsp&quot; version=&quot;1.0&quot; exclude-result-prefixes=&quot;xsl msxsl ddwrt&quot; xmlns:ddwrt=&quot;http://schemas.microsoft.com/WebParts/v2/DataView/runtime&quot; xmlns:asp=&quot;http://schemas.microsoft.com/ASPNET/20&quot; xmlns:__designer=&quot;http://schemas.microsoft.com/WebParts/v2/DataView/designer&quot; xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot; xmlns:msxsl=&quot;urn:schemas-microsoft-com:xslt&quot; xmlns:SharePoint=&quot;Microsoft.SharePoint.WebControls&quot; xmlns:ddwrt2=&quot;urn:frontpage:internal&quot;&gt;
	&lt;xsl:output method=&quot;html&quot; indent=&quot;no&quot;/&gt;
	&lt;xsl:decimal-format NaN=&quot;&quot;/&gt;
	&lt;xsl:param name=&quot;dvt_apos&quot;&gt;'&lt;/xsl:param&gt;
	&lt;xsl:variable name=&quot;dvt_1_automode&quot;&gt;0&lt;/xsl:variable&gt;
	&lt;xsl:template match=&quot;/&quot; xmlns:x=&quot;http://www.w3.org/2001/XMLSchema&quot; xmlns:d=&quot;http://schemas.microsoft.com/sharepoint/dsp&quot; xmlns:asp=&quot;http://schemas.microsoft.com/ASPNET/20&quot; xmlns:__designer=&quot;http://schemas.microsoft.com/WebParts/v2/DataView/designer&quot; xmlns:SharePoint=&quot;Microsoft.SharePoint.WebControls&quot;&gt;
		&lt;xsl:call-template name=&quot;dvt_1&quot;/&gt;
	&lt;/xsl:template&gt;
	&lt;xsl:template name=&quot;dvt_1&quot;&gt;
		&lt;xsl:variable name=&quot;dvt_StyleName&quot;&gt;Table&lt;/xsl:variable&gt;
		&lt;xsl:variable name=&quot;Rows&quot; select=&quot;/dsQueryResponse/Rows/Row&quot;/&gt;
		&lt;xsl:variable name=&quot;dvt_RowCount&quot; select=&quot;count($Rows)&quot; /&gt;
		&lt;xsl:variable name=&quot;IsEmpty&quot; select=&quot;$dvt_RowCount = 0&quot; /&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js&quot;&gt;&lt;/script&gt; &lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;sample.css?t=1&quot; /&gt;
	&lt;script type=&quot;text/javascript&quot; src=&quot;captify.tiny.js&quot;&gt;&lt;/script&gt; &lt;script type=&quot;text/javascript&quot;&gt;
this.randomtip = function(){
	var pause = 9000; // define the pause for each tip (in milliseconds)
	var length = $(&amp;quot;#headers li&amp;quot;).length;
	var temp = -1;
	this.getRan = function(){
		var ran = Math.floor(Math.random()*length) + 1;
		return ran;
	};
	this.show = function(){
		var ran = getRan();
		while (ran == temp){
			ran = getRan();
		};
		temp = ran;
		$(&amp;quot;#headers li&amp;quot;).hide();
		$(&amp;quot;#headers li:nth-child(&amp;quot; + ran + &amp;quot;)&amp;quot;).fadeIn(&quot;slow&quot;);
	};
	show(); setInterval(show,pause);
};
&lt;/script&gt; &lt;script type=&quot;text/javascript&quot;&gt;
	$(function(){
		$(&amp;apos;img.captify&amp;apos;).captify({});
	});
	$(document).ready(function(){
	randomtip();
});
	&lt;/script&gt; &lt;style type=&quot;text/css&quot;&gt;
#headers, #headers li{
	margin:0;
	padding:0;
	list-style:none;
	}
#headers li img{
	display:none; /* hide the items at first only */
	}
&lt;/style&gt;
&lt;ul id=&quot;headers&quot;&gt;
	&lt;xsl:call-template name=&quot;dvt_1.body&quot;&gt;
	&lt;xsl:with-param name=&quot;Rows&quot; select=&quot;$Rows&quot;/&gt;
	&lt;/xsl:call-template&gt;
&lt;/ul&gt;
	&lt;/xsl:template&gt;
	&lt;xsl:template name=&quot;dvt_1.body&quot;&gt;
		&lt;xsl:param name=&quot;Rows&quot;/&gt;
		&lt;xsl:for-each select=&quot;$Rows&quot;&gt;
			&lt;xsl:call-template name=&quot;dvt_1.rowview&quot; /&gt;
		&lt;/xsl:for-each&gt;
	&lt;/xsl:template&gt;
	&lt;xsl:template name=&quot;dvt_1.rowview&quot;&gt;
&lt;li&gt;&lt;img border=&quot;0&quot; src=&quot;{@FileRef}&quot; alt=&quot;{@Title}&quot; class=&quot;captify&quot; title=&quot;{@Title}&quot;/&gt;&lt;/li&gt;
&lt;/xsl:template&gt;&lt;/xsl:stylesheet&gt;&lt;/XSL&gt;
</pre>
<h1>How it works</h1>
<p>This code displays the items from our list in an unordered list and then using the <a href="http://cssglobe.com/post/6023/simple-way-to-random-display-or-rotate-content-using">jQuery method explained here</a> it randomly chooses one to display. Initially they are all hidden by this css.</p>
<pre class="brush: css;">
&lt;style type=&quot;text/css&quot;&gt;
#headers, #headers li{
	margin:0;
	padding:0;
	list-style:none;
	}
#headers li img{display:none; /* hide the items at first only */}
&lt;/style&gt;
</pre>
<p>You can remove this from the xsl code and put it in your own external style sheet if you want. If you look at <a href="http://cssglobe.com/post/6023/simple-way-to-random-display-or-rotate-content-using">the article on CSS Glob</a>e where I got the code from there is also a way to make it show images randomly on page refresh.To diplay the captions I am using the <a rel="no-follow" href="http://ignati.com/captify-jquery-plugin-to-display-image-captions/">Captify jQuery plugin</a>. If you notice in the xsl I am adding a class of &#8216;captify&#8217; to each image, this is all the plugin needs to work. We just need to reference the plugin file and call the function like this:</p>
<pre class="brush: jscript;">
&lt;script type=&quot;text/javascript&quot;&gt;
	$(function(){$('img.captify').captify({});
	});  //show captions on the images
	$(document).ready(function(){randomtip();
});  //display the random images
	&lt;/script&gt;
</pre>
<h1>In closing</h1>
<p>I have seen other methods of showing random content in the Data View Web Part such as this one:</p>
<pre class="brush: plain;">
&lt;xsl:variable name=&quot;Rows&quot; select=&quot;/dsQueryResponse/Rows/Row[@ID=ddwrt:Random(1,count(//Rows/Row))]&quot;/&gt;
</pre>
<p>However when I experimented with it there were issues with it choosing id&#8217;s that were not in the list and therefore nothing would display. If any one knows of an alternative solution please let me know.Overall this can be a very powerful tool for sharing information with your users. With a few small edits to the code and the list you can easily make each slide link to a page or a list item on your site.</p>
<p>If you have trouble getting this working on your site make sure the references to jQuery and the Captify script are correct, if they are right and you still have issues feel free to post a comment and I&#8217;ll do what I can to help out.</p>
<h1>Resources</h1>
</ol>
<ul>
<li><a rel="no-follow" href="http://www.jquery.com">jQuery</a></li>
<li><a rel="no-follow" href="http://github.com/caius/jquery-captify">Captify Plugin Download</a></li>
<li> <a rel="no-follow" href="http://cssglobe.com/post/6023/simple-way-to-random-display-or-rotate-content-using">Simple Way to Random Display or Rotate Content Using JavaScript and CSS</a></li>
</ul>


<p>Related posts:<ol><li><a href='http://davecavins.com/2010/04/anything-slider-in-sharepoint-update/' rel='bookmark' title='Permanent Link: Anything Slider in SharePoint &#8211; Update'>Anything Slider in SharePoint &#8211; Update</a></li>
<li><a href='http://davecavins.com/2010/04/switch-list-displays-with-jquery-and-css/' rel='bookmark' title='Permanent Link: Switch List Displays with JQuery and CSS'>Switch List Displays with JQuery and CSS</a></li>
<li><a href='http://davecavins.com/2009/12/css-tricks-anythingslider-in-sharepoint/' rel='bookmark' title='Permanent Link: CSS-Tricks AnythingSlider in SharePoint'>CSS-Tricks AnythingSlider in SharePoint</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://davecavins.com/2010/01/displaying-a-rotating-header-image-with-caption/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
