Microsoft cloud engineer - SharePoint, Office 365, Azure, DotNet, Angular, JavaScript.
Microsoft cloud engineer - SharePoint, Office 365, Azure, DotNet, Angular, JavaScript.


MOVIE – Random Tip – XSLT

So you want to display a single random item from a SharePoint list?     It’s a common request and a very handy one for visitors.    Give your site a fresh relevant appearance with a dynamic web part.    Web 2.0 requires us site designers to keep pace with visitor expectations.   Let’s get to the fun part.    Here we’ll be using the Data Form Web Part (DFWP) sometimes called the Data View Web Part (DVWP) to present a SharePoint list with XSLT logic for the randomizer and conditional formatting to only show the target record.

Example Code   (random row XSLT.txt  1KB)
Sample Data     (Email Security Tips.xls  13KB)


Watch this 4 minute movie clip to see a live demo.     Steps are outlined below also.




  1. Create your list
  2. Open the target page in SharePoint Designer 2007
  3. Open Data View Manage Data Sources
  4. Ctrl+Click the Title and Body columns     (NOTE – other column names work too)
  5. Drag them on the page
  6. Add two CSS classes to the page header
  7. Locate the XSLT header with “<xsl:variable” entries and confirm you have the below three:
  8. Locate the <TR> for starting a new row.   Add the conditional pair below to apply the right CSS class when needed.
  9. Apply extra formatting  (bold, colors, icons) to achieve a unique look for your audience.

JQuery Accordion – Expand Collapse All

I looked over many threads and posts on many sites and wasn’t able to find code that worked for me.    Some of it would be close.   Others buggy.   Below I’ve outlined the JQuery code that worked perfectly for my needs and I hope you find it helpful too.

This example was deployed to a SharePoint page so the “/_layouts/images/plus.gif” was used to leverage the OOTB graphics for a plus/minus icon feel.

Full Example Source Download     (  73KB)






Parent .HTML

Expand All

First Header

first body

Second Header

second body

Third Header

third body

Supporting .JS

// bind to accordion object
		header: “h3?
// actions taken upon clicking the expand all (collapse all) link
$('#container #expand').click( function() {
	// if link was expand then show and toggle text
	var currHTML = $('#container #expand').html();
	if (currHTML.indexOf(“Expand All”)>0) {
		$('#container .section').slideDown();
		$('#container #expand').html(“
Collapse All”); } else { // if link was collapse then hide and toggle text $('#container .section').slideUp(); $('#container .section').each(function(i){ if (i==0) $(this).slideDown(); }); $('#container #expand').html(“
Expand All”); } });

© Copyright 2016
@ SPJeff

Return to Top ▲Return to Top ▲