Category Archives: SharePoint Designer

Design Manager and The Return of the Snazzy Looking 15 Minute Weather Web Part


You may also be interested in: fpweb.net


 

Editor’s note: Contributor Erik Abderhalden is a consultant with Rightpoint. Follow him @erikboderek

They say there’s only two seasons in Chicago: construction and winter. Thankfully most of the major highway and tolls are construction free now (sans I-90 west of 290), and winter is a while away. Or is it? Chicago weather is downright bizarre. How do you keep tabs on what it’s like outside? 15 minute weather web part to the rescue!

What I love about the 15 minute weather web part is how easy it is to style. Unlike other weather web parts, you can really get into this one and style it however you want. In my initial post this would just be another ol’ web part sitting pretty in a zone. What if I’m too cool for zones? OK Fonzie, chill. We can create the weather web part as a snippet and place it anywhere we want and style it however we want. Since we’re too cool for zones, we can even embedded in – wait for it – the master page.

Thanks to the HTML snippet generator in SharePoint 2013 you can place it anywhere you want in the master page. Here’s how. Make sure Publishing is enabled on your site first.

  1. Download jQuery Tools here and zWeatherFeed here and place them in your site. Download jQuery too – especially if your master page isn’t already using it.
  2. Follow the configuration steps in my original post (stop after the first code block)
  3. Save the code as a text file
  4. Upload the text file to your Style Library and publish it
  5. Follow steps 1-5 here.
  6. In the Design tab select Media and Content > Content Editor
  7. 2013-11-12-WeatherWebpart-Part02-01.png

  8. In the content link property, enter the URL of where the text file from step 4 was uploaded
  9. Expand the Appearance section and set Chrome Type to None
  10. Click the Update button right of the web part properties
  11. 2013-11-12-WeatherWebpart-Part02-02.png

  12. Click Copy to Clipboard. Don’t worry that the preview is empty.
  13. Open up your master page in SharePoint Designer
  14. Make sure you open up the HTML version of your master page and not the .master
  15. Look for SharePoint: AspMenu ID="TopNavigationMenu". A line or two after it there should be a / asp: ContentPlaceHolder> and a / SharePoint: AjaxDelta> . Create a div with the class "weather".
  16. Paste the content copied from the snippet generator inside that div. It should look something like this:
  17. 2013-11-12-WeatherWebpart-Part02-03.png

  18. Save the master page and check out your site

OK – so it looks a little wonky. Let me help you with some CSS. Throw this in a CEWP or reference it via an external stylesheet in your master page. This won’t be perfect because the position of the classes depends on other elements in your master page, but this should whet your appetite.



When done, your web part should look like this. If you have multiple locations in your text file, the web part will rotate through them as well.

2013-11-12-WeatherWebpart-Part02-04.png

I wanted to share one caveat. If you’re using design manager to package up your publishing assets to move between environments or create a boilerplate site template, leaving the 15 minute weather web part, or any other web part embedded in the master page, is a bad idea. Strange things happen when you import the package. I’ll save you the headache now instead of later.

Finally I need to share some credit where credit is due. This post wouldn’t be possible without the help of my awesome coworker Liz Sdregas.

Review of the SharePoint Designer and XSLT Coverage in Pluralsight’s Course “Advanced SharePoint 2010 Branding for Web Designers” – Part IV: Yet More Extensive XML and XSLT in SharePoint Designer

 

Editor’s note: Contributor Stephan Onisick is a Senior Software Developer for HP specializing in SharePoint Portal Applications. Follow him @StephanOnisick

The final part of this outstanding section shows SharePoint as an even more capable XSLT generator (well, sometimes). Ted uses a SharePoint Picture Library of his Wingtip Toys for a List View XSLT Web Part. He notes that out-of-the-box SharePoint (OOTB) does not have a view that will natively render images in a Web Part. . (That’s why there are expensive SharePoint Developers. Don’t ya just hate this!)

This would be daunting for mere mortals, but Super Ted pulls off his gloves and goes wading into raw code to display a view that works in the SharePoint Designer Split View (but unfortunately not in the browser).

Bear with me one last time, as I attempt to reconstruct the missing library from screen captures of Wingtip Toys. My picture library was created by using the Snipping Tool from my desktop on the Toy Slides I could glean from this Pluralsight Course:

2013-06-10-SharePointDesignerXSLTCoverage-Part04-01.png
Figure 1 Windows Snipping Tool

(This is also left for viewers to create a SharePoint Picture Library called “Wing Tip Toys” should they desire to follow the code in detail.)

The procedure is similar to the last one I outlined:

  1. First create a Web Part Page.
  2. Then add the “Wing Tip Toys” SharePoint Picture Library from the “Lists and Libraries” Group of Web Parts

The point after the user has selected “Edit Web Part” in the browser is where my narrative and illustrations continues. This is where Ted sets two properties:

2013-06-10-SharePointDesignerXSLTCoverage-Part04-02.png
Figure 2 Edit Web Part Properties in the Browser

The properties that he sets are “Toolbar Type” to “None” and under the Appearance Section, “Chrome” to “None”:

2013-06-10-SharePointDesignerXSLTCoverage-Part04-03.png
Figure 3 No Toolbar and No Chrome Set in Web Part Properties

(Note: Because of the different properties available and the relative ease of setting one in the browser versus SharePoint Designer, there is a need for both. Not all properties can be set from both modes. It takes some experimentation to figure out the best place to change a given property.)

Next the “Edit Mode” of the Web Page is exited to preserve changes. Then SharePoint Designer is opened as in the previous example and the Web Part Page is edited in Advanced Mode.

The following display Continues with the Web Page open with SharePoint Designer in “Split” Mode:

2013-06-10-SharePointDesignerXSLTCoverage-Part04-04.png
Figure 4 SharePoint Designer in "Split" Mode showing Wing Tip Toys Web Part

Just as Ted noted, the fields currently showing are not the correct ones for displaying the images. Also note that no images are currently showing in the “Design” View above.

So the next step is to ‘click’ inside the first displayed row so that the context of SharePoint Designer changes and the “Add Remove Column Fields” Tool is displayed in the top toolbar:

2013-06-10-SharePointDesignerXSLTCoverage-Part04-05.png
Figure 5 Add/Remove Columns showing with open dialogue

All “Displayed Fields” need to be removed and consequently are removed by selecting them individually and clicking the “<<Remove” button.

Next, the following fields are added: “Title” and “URL Path”:

2013-06-10-SharePointDesignerXSLTCoverage-Part04-06.png
Figure 6 Title and URL Path Added

The newly displayed “Design View” looks as follows:

2013-06-10-SharePointDesignerXSLTCoverage-Part04-07.png
Figure 7 Title and Url Path in Design Web Part

Next the “Page Size” Option is set by using the “Paging” Tool in the Top toolbar:

2013-06-10-SharePointDesignerXSLTCoverage-Part04-08.png
Figure 8 Paging Option set from Toolbar

The goal here is to set the Display Set of Items large enough that pagination never kicks in to spoil our pristine display. Since my library only has about 6 images, a lower value could have been selected.

Next we allow SharePoint Designer to do the formatting by clicking on the “Design” Tab and then choosing to format with the “Boxed, no Labels” tool:

2013-06-10-SharePointDesignerXSLTCoverage-Part04-09.png
Figure 9 "Boxed, no labels" tool outlined in red

Alas, finally we need to look at the XSLT. At this point SharePoint Designer needs to show us the internals of the XSLT so that we can customize. We ask the SharePoint Designer to do this by the “Customize XSLT” dropdown to select “Customize Entire View”:

2013-06-10-SharePointDesignerXSLTCoverage-Part04-10.png
Figure 10 Customize XSLT/Customize Entire View outlined

The cursor is now placed on the first URL Path with the code selected in “Code View”:

2013-06-10-SharePointDesignerXSLTCoverage-Part04-11.png
Figure 11 First URL Path Selected after Converting Entire View

Next the off-roading begins. The code section that is selected needs to be encased with an Image Tag, “<img></img>”, and an XSLT Attribute Tag, “<xsl:attribute

2013-06-10-SharePointDesignerXSLTCoverage-Part04-12.png
Figure 12 Adding XSLT Attribute

The following shows the completed code alteration with the image and the attribute:

2013-06-10-SharePointDesignerXSLTCoverage-Part04-13.png
Figure 13 Toy Trains in SharePoint Designer

It is apparent from the display that SharePoint Designer is able to render the images.

Alas, Poor Yorick! Ye old browser is not totally convinced of the image worthiness:

2013-06-10-SharePointDesignerXSLTCoverage-Part04-14.png
Figure 14 Browser Fails to render images – Ever have one of those days?

At this point, after a couple “Rinse and Repeat” sessions and consulting the oracles at Google. I chanced on the following snippet from an article from SharePoint Stack Exchange (http://sharepoint.stackexchange.com/)

Sharepoint Designer – Inserting an xsltListView Webpart generates xslt transform failed error (http://goo.gl/0dFeA)

2013-06-10-SharePointDesignerXSLTCoverage-Part04-15.png
Figure 15 MARC ANDERSON (XSLT Gold)

Anytime you see Marc D Anderson and XSLT in the same blog—you have hit the “Holy Grail of XSLT” and been granted safe passage through the gnarls.

My next thought was maybe there’s an unwrapped “ddwrt:UrlDirName” on the page.

(Don’t you love it when a plan comes together!)

As it turns out, the offending line is:

2013-06-10-SharePointDesignerXSLTCoverage-Part04-16.png
Figure 16 Not Wrapped by string: <xsl:value-of select

The following is a view of the line that allows the browser to output images correctly :

2013-06-10-SharePointDesignerXSLTCoverage-Part04-17.png
Figure 17 string() surrounds <xsl:value-of select

(If this does not appear obvious to you—you’re not alone!)

The following is a display of the Web Part in the browser:

2013-06-10-SharePointDesignerXSLTCoverage-Part04-18.png
Figure 18 Solution in Browser –Even works in SharePoint!!

In Conclusion

While Ted did not have a solution to every issue in this section of XML, XSLT and SharePoint Designer, he provided me with inspiration. That is what a good educator does and my hat is off to his mastery.

The technology is not easy but it’s approachable as long you look for guides, blogs, mentors, gurus, and keep conversant with Google.

If you found this series useful—connect with me on linkedin www.linkedin.com/in/stephanonisick or twitter @StephanOnisick. Your comments could help mold future articles. (Power is scary isn’t it?)

Until my next inspiration—Happy SharePointing!
Stephan

Review of the SharePoint Designer and XSLT Coverage in Pluralsight’s Course “Advanced SharePoint 2010 Branding for Web Designers” – Part III: More Extensive XML and XSLT in SharePoint Designer

 

Editor’s note: Contributor Stephan Onisick is a Senior Software Developer for HP specializing in SharePoint Portal Applications. Follow him @StephanOnisick

The next two demos show the adeptness of SharePoint Designer at generating gnarly XSLT code for you.

[It’s worth noting that neither of these demos display correctly in Ted’s browser after he finishes coding. For a developer, this is funny but not totally unexpected: The environment is complex and SharePoint Designer can be snarky—even the new improved SharePoint 2010 Designer.]

Before going into these demos, I want to emphasize Ted’s “Rinse and Repeat” Strategy. The condensed version goes like this:

  1. Create your basic Web Part Page in a location you can later find.
  2. Add your Web Part (List View, Content Web Editor, or whatever).
  3. Exit the “Edit Page”—so the Page is actually saved.
  4. Customize that Page and the specific Web Part in SharePoint Designer in “Edit File in Advanced Mode”.
  5. If and when you get toasted by the Designer (as even Ted did in the demos)—start back at Step 1.

For this demo, Ted creates a Web Part on the page from a SharePoint List on his site.

Since I don’t have Ted’s SharePoint Site and his Customer List, I’m using a simple Author List that I modified from another Pluralsight Course. The relevant fields are: Name (Single Line of Text), Employee (Yes/No), and Salary/Rate (Numeric with 2 decimal places). My code views are predicated on this table structure. (If the viewer desires to follow along, they should recreate this list with the above structure on their system.)

The next four illustrations show this List added to a SharePoint Web Part Page—which then becomes a XSLT List View Web Part. (See the sneaky way SharePoint inserts the XSLT!)

First create the Web Part Page as follows:

2013-06-05-SharePointDesignerXSLTCoverage-Part03-01.png
Figure 1 Basic Web Part Page Create – Step 1

2013-06-05-SharePointDesignerXSLTCoverage-Part03-02.png
Figure 2 Basic Create of Web Part Page – Part 2

2013-06-05-SharePointDesignerXSLTCoverage-Part03-03.png
Figure 3 After Adding Authors List from the “Lists and Libraries” Web Parts Group

Next “Stop Editing”:

2013-06-05-SharePointDesignerXSLTCoverage-Part03-04.png
Figure 4 Web Part after Exiting Edit Mode

Then open the file in SharePoint Designer:

2013-06-05-SharePointDesignerXSLTCoverage-Part03-05.png
Figure 5 SharePoint Designer Accessed from Site Actions.

(Sometimes it is physically necessary to open SharePoint Designer from the Start Button and navigate to the page if the option does not appear on the Site Actions Menu.)

Next choose “Edit File in Advanced Mode” by selecting the option from the context-click (right-click):

2013-06-05-SharePointDesignerXSLTCoverage-Part03-06.png
Figure 6 Edit File in Advanced Mode

To illustrate conditional formatting in SharePoint Designer, I arbitrarily chose to highlight each row in green where the Salary/Rate is greater than 500.

First, the web page is viewed in “Split” Mode and my cursor is show in the first row.

2013-06-05-SharePointDesignerXSLTCoverage-Part03-07.png
Figure 7 Beginning Conditional Formatting

The tool bar changes to the “List View Tools” after clicking into a column in a data row of the “Design” portion of the “Split” View.

Note the toolbar with the “Conditional Formatting Tool :

2013-06-05-SharePointDesignerXSLTCoverage-Part03-08.png
Figure 8 Conditional Formatting Tool on Web Part Toolbar

Next “Format Row” is chosen from the “Conditional Formatting” dropdown:

2013-06-05-SharePointDesignerXSLTCoverage-Part03-09.png
Figure 9 Format Row

The idea is to select a field that contains values that need to be highlighted. Then apply highlighting to the entire row whenever this condition is encountered in a row.

The Plurasight/CriticalPath Course Slide displays a good overall representation of the “Format Row” dropdown combined with “Set Style” button:

2013-06-05-SharePointDesignerXSLTCoverage-Part03-10.png
Figure 10 Pluralsight Course Slide Overview for Format Row

My example uses a different field for comparison from the one Ted used in his example. Because of SharePoint naming quirks, the actual field name is “Salary_x002f_Rate” The slash character in “Salary/Rate” gets converted to “_x002f_” automagically by SharePoint. (Hint: For sanity, avoid spaces and special characters like slashes in columns.)

This field does not show up in the original list and must be selected from the “More Fields” Option of the “Field Name” dropdown.

2013-06-05-SharePointDesignerXSLTCoverage-Part03-11.png
Figure 11 Field Selected from “More Fields”

The following shows the display of the complete comparison:

2013-06-05-SharePointDesignerXSLTCoverage-Part03-12.png
Figure 12 Complete Compare

Next the “Set Style” button is clicked to open the “Modify Style” dialogue:

2013-06-05-SharePointDesignerXSLTCoverage-Part03-13.png
Figure 13 Modify Style Dialogue to Change Background to Green

The following shows a partial listing of the generated XSLT:

2013-06-05-SharePointDesignerXSLTCoverage-Part03-14.png
Figure 14 Partial XSLT List with Ugliest Code Marked

(Scary isn’t it? –No Human Beings were harmed in its creation –although overexposure to XSLT can result in blurred vision, headaches, and atrocious language.)

This concludes the examination of XSLT and Conditional Formatting. Part IV will cover more extensive Pattison off-roading in the SharePoint Designer with a SharePoint Picture Library.

Happy SharePointing,
Stephan

Review of the SharePoint Designer and XSLT Coverage in Pluralsight’s Course “Advanced SharePoint 2010 Branding for Web Designers” – Part II: XML and XSLT in SharePoint XML Viewer Web Part

 

Editor’s note: Contributor Stephan Onisick is a Senior Software Developer for HP specializing in SharePoint Portal Applications. Follow him @StephanOnisick

Next, Ted hones in on using XSLT within SharePoint.

You gotta love this: Ted’s emphasis is to not get mired in the XSLT Code. His motto is let SharePoint Designer do most of the work. Then, just modify what has to be changed.

How often as developers have we gotten knee-deep in XSLT, and then lost our precious thread of logic while waiting for SharePoint Designer to returns from its extraterrestrial excursions.

Remember how SharePoint 2007 Designer reformatted your code–sometimes to something unworkable? Forget about aligning code—in a blink of an eye it was history in SharePoint Designer.

Or worse yet, remember how the SharePoint 2007 Designer would occasionally introduce extra tags, like form tags, and then complain about them and stop rendering HTML?

2013-05-31-SharePointDesignerXSLTCoverage-Part02-01.png
Figure 1 Pluralsight Course Slide using XSLT with SharePoint

The next set of presentations cover the first two bullet points in depth. The last two are only mentioned to note their use and importance in SharePoint.

Note: One disconcerting thing to be aware of is there are NO Exercise Files for this segment available in download. The files used Are NOT the same files Ted used for the simple demos on XML and XSLT.

This causes a little inconvenience in requiring the user to first create the files, lists and libraries needed to be able to follow along with the modifications Ted presents.
(On the bright side, we learn by doing. :-)

XML Viewer Web Part in SharePoint

The next two demos utilize the XML Viewer Web Part. What the XML Viewer Web Part does is to essentially separate the XML file and the XSLT file (Data from Presentation). This allows the user to experiment with different XSLT files for displaying a given XML file. Thus, they can completely change the look of an XML file by simply changing the name of the XSLT Transform file. This Web Part, then, renders or displays the transformed html on the SharePoint Web Page.

Ted takes a different set of files (as previously noted) and drags them into SharePoint Designer. Then he hooks them up to the XML View Web Part. He uses these files in almost the same way he used the stand-alone XML and XSLT files. This works on the same concepts already explored but propels the learning squarely into the SharePoint Arena.

As Ted begins to work with the demo code, he shows the user how to modify the XSLT in SharePoint Designer to add additional markup. SharePoint Designer leverages Intellisense in conjunction with a superb XPATH Expression Editor to ease the pain of coding god-awful XSLT syntax. His emphasis is to let SharePoint do the “grunt” work. You, the designer, just modify the bare minimum to achieve the effect needed.

The first example for SharePoint Designer is fairly straight forward and needs no expounding.

The second example, however, gets interesting.

Because both code files are salient to the second example, and were not included in the download, I have included the code below as text so that it can be copied:

demo02.XML:


<HotLinks>
<Link>
    <Title>CSS Property Reference</Title>
    <URL>http://www.w3.org/TR/CSS21/propidx.html</URL>
    <Comments>Document which specifies CSS properties for version 2.1.</Comments>
</Link>
<Link>
    <Title>CSS3 Maker</Title>
    <URL>http://css3maker.com</URL>
    <Comments>Get CSS 3.0 Layouts</Comments>
</Link>
<Link>
    <Title>ColorSchemer</Title>
    <URL>http://www.colorschemer.com</URL>
    <Comments>Site to help you pick a color scheme.</Comments>
</Link>
<Link>
    <Title>Lorem2</Title>
    <URL>http://www.lorem2.com</URL>
    <Comments>A site where you can get chunks of Latin content for Greeking.</Comments>
</Link>
<Link>
    <Title>Add This</Title>
    <URL>www.addthis.com</URL>
    <Comments>Copy-and-paste elements for pages.</Comments>
</Link>
</HotLinks>

demo02.xsl:


<?XML version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" mlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="html"/>
  
  <xsl:template match="/">

   <h2>Hot Links for SharePoint Web Designers</h2>

    <ul style="font-size: 10pt">
        <xsl:for-each select="HotLinks/Link">
            <li>
                  <xsl:value-of select="Title"/>
              </li>
      </xsl:for-each>
    </ul>
  </xsl:template>
</xsl:stylesheet>

(Note: Make sure the quotation marks look correct and are not angled as in Word when you “Copy and Paste”. I usually paste into Notepad first. Then copy again from Notepad and paste into SharePoint Designer. This circumvents some of the problems.)

The first display of this example shows just text strings after the bullet points. As such, it is worthless to the user for navigation to the named sites:

2013-05-31-SharePointDesignerXSLTCoverage-Part02-02.png
Figure 2 XSLT Rendered in the XML Viewer Web Part
Note: Outlined Area is Text

Fearless Ted rectifies this by changing SharePoint Designer to render anchor tags and dynamic hyperlinks. Instead of displaying text, the “new and improved” Web Part displays a navigation link (hyperlink). Thus, the user has something useful for navigation to any of the sites listed.

To do this he changes the text display to an anchor tag and then adds a dynamic XSLT:attribute to render each URL:

2013-05-31-SharePointDesignerXSLTCoverage-Part02-03.png
Figure 3 Dynamic <xsl:attribute Added within the anchor tag

This results in a more useful Web Part with links/anchors instead of text. The amount of XSLT Changing was minimal—all of which was aided by handy-dandy SharePoint Designer Intellisense. (Don’t leave home without it!)

2013-05-31-SharePointDesignerXSLTCoverage-Part02-04.png
Figure 4 XSLT Rendered with Anchor Tags
(The first bullet shows a previously visited hyperlink)

This concludes the examination of the SharePoint XML Viewer Web Part. Part III will cover more XSLT in SharePoint Designer including Conditional Formatting Logic.

Happy SharePointing,
Stephan

Review of the SharePoint Designer and XSLT Coverage in Pluralsight’s Course “Advanced SharePoint 2010 Branding for Web Designers” – Part 1

 

Editor’s note: Contributor Stephan Onisick is a Senior Software Developer for HP specializing in SharePoint Portal Applications. Follow him @StephanOnisick

I almost overlooked this gem of a course in the pack of 57 SharePoint Courses on Puralsight.com. The title sounded similar to at least four other courses in the SharePoint Curriculum on Pluralsight.com. I’m glad I didn’t and chose instead to review it in depth.

It is hard in the midst of so many good courses to keep them all differentiated. At this time, Pluralsight lacks a personal history navigation interface: one where you can tell at a glance the courses taken and the current state of your progress in a given course. (Hint! Hint! Pluralsight!)

(Yes, there is a “Your history and bookmarks” displayed under your login name – but it only bookmarks the last 10 courses you’ve visited – barely a month’s worth for some of us more avid users!)

When I finally reviewed “Advanced SharePoint 2010 Branding for Web Designers”, I realized this course was huge in SharePoint learning experience and breadth of technology. To do this offering justice, I needed to do more than just casually watch the technology stream by on my monitor. This called for something more proactive which included building the demos on my home SharePoint 2010 virtual machine along with the videos presented by Mr. Guru, Ted Pattison.

As a SharePoint Developer of almost five years, I have found good coverage from the ground up of XML, XSLT and SharePoint Designer sorely lacking in SharePointdom. There are, of course, expert blogs on these topics but the complexity of the presentations frequently obscures any insights for us mere mortals.

Ted Pattison has long been a giant in SharePoint (heck, before that he was huge in COM+ programming. I’m pretty sure this dates both of us! Groovy! huh?).

It took Ted Pattison’s consummate skill to expound on XML, XSLT, and SharePoint Designer. He provides a workable pathway through this dense forest of learning.

On any of these topics, it would have been easy to leave the student stranded in the weeds. This didn’t happen. Ted provided a workable approach that lays claim to the basic principles of each discipline.

(You can quote me! I already have!)

Beyond XSLT and SharePoint 2010 Designer, the course covers the additional topics of Clientside Coding JavaScript/jQuery, Upgrading from SharePoint 2007 to SharePoint 2010, and Sandbox Solution Deployment. (All have good coverage, depth and insight.)

Because of the uniqueness and novelty of Ted’s approach on the coverage of the XSLT and SharePoint Designer Integration, I have chosen to focus this article exclusively on these topics.

To allow depth for this topic I have segmented this piece into 4 parts for easier consumption by readers (The Mind can’t absorb more than the Seat.):

  • The first covers basic XSLT Transforms of XML outside of SharePoint.
  • The second covers XSLT within the SharePoint XML Viewer Web Part.
  • The third covers SharePoint 2010 Designer more extensively with Conditional Logic and more complex XSLT Transforms.
  • The final segment covers the XSLT involved in displaying a SharePoint Picture Library with extensive off-roading in SharePoint Designer.

My hope is that these four parts will serve as an addendum and adjunct to an innovative course.

Part I: Almost Bare Naked XML and XSLT

What makes this coverage interesting is the utility of the examples being used. Ted starts with basic XML and XSLT rendered just in the browser from an html wrapper. Then he progresses to one of the most complex tools in this author’s estimation, SharePoint 2010 Designer.

He entitles a section “World’s Fastest Introduction to XSLT”. I haven’t previously had occasion to use “fastest” and “XSLT” in the same sentence—or even the same paragraph for that matter. His video and examples provide the student with material to work through this maze and emerge knowledgeable.

To render each XML File with a custom XSLT Transform, the examples use an Html Page called “Default.htm”:

2013-05-28-SharePointDesignerXSLTCoverage-Part01-01.png
Figure 1 The Html Wrapper used to display XML/XSLT (Default.htm) via the “href” attribute in the anchor tag.

Note: The individual files (demo01.xml, demo02.xml, and demo03.xml) may be rendered/displayed directly in Internet Explorer by right-clicking on the XML File. The browser will render the transformed HTML.

The HTML simply references the XML files from three anchor tags. The XML Files, in turn, call the specific XSLT File on the second line. (There is some eye-candy in the form of a cute airplane banner, Site Title and a menu formatted by some CSS and images. These can be safely ignored.)

The following shows the first example,”Demo 1”, in its entirety:

2013-05-28-SharePointDesignerXSLTCoverage-Part01-02.png
Figure 2 Basic "Hello World" XML

2013-05-28-SharePointDesignerXSLTCoverage-Part01-03.png
Figure 3 First Simple XSLT Code

2013-05-28-SharePointDesignerXSLTCoverage-Part01-04.png
Figure 4 Output of a Simple XSLT Transform
(Note: the Banner originates from the Html Wrapper which includes the top menu.)

The first two examples, “Demo 1” and “Demo 2”, do not use XML Namespaces in the XSLT Code and the XML pages can be edited from Notepad or Notepad++ editor.

(Notepad++ has a nice feature to render the XML in several different browsers—if they are installed on your machine. Ted actually uses Visual Studio 2010 to edit the files for the added benefit of using its Intellisense. The XSLT code, in these first two examples, is not complex and Notepad will do fine for these.)

The next example, “Demo 2”, displays a simple phone list formatted by an XSLT Transform.

2013-05-28-SharePointDesignerXSLTCoverage-Part01-05.png
Figure 5 Second Simple XSLT Transform
(Code Not Shown in Article)

The third example, “Demo 3”, is a much more complex form and uses an XML Namespace in the XSLT Code:

2013-05-28-SharePointDesignerXSLTCoverage-Part01-06.png
Figure 6 Third example with a markedly more complex XSLT Transform
(Note: Header from HTML Wrapper is Not Displayed and the Code is Not Shown in Article)

Ted’s purpose in the last example is not to completely explain the complex XSLT. His aim is more to give the student a working example of XSLT capability they can take apart, examine, experiment with, copy and use.

An interesting exercise for the reader is to make the third example work without the XML Namespace. This gives insight to the use of XML Namespaces.

This concludes the basic XML and XSLT Transforms. Part II will continue with XML Web Viewer.

Happy SharePointing!
Stephan

Yes, the SharePoint navigation really can work for your needs


You may also be interested in: O’Reilly – SharePoint 2010 at Work


 

Editor’s note: Follow contributors Heather Solomon and Dustin Miller @spexperience

A commonly misunderstood component of SharePoint is the navigation. We are frequently asked in class about how to make changes to the navigation and when we cover it, people are really surprised and honestly, it is pretty anti-climatic! Here are a few things everyone should know about manipulating SharePoint navigation.

Your best friend is Site Settings

Site Settings is the first thing to get to know for SharePoint navigation. It can also be a little confusing at first because based on the type of site you are using, different options will appear. Check out the screenshot below.

2013-04-24-SharePointNavigation-01.png

If you are working with a publishing site (for example a site created from the Publishing or Enterprise Wiki template) then when you go to Site Actions > Site Settings in your SharePoint 2010 site, you will see Navigation as an option under the Look and Feel column. If you working with a team site, you will see Quick Launch and Top link bar. But if you are working with a team site that is a child of a publishing site, well then you see Navigation.

Publishing gives you more options

One of the benefits of using the SharePoint publishing features is a more robust and centralized navigation system. The key thing to remember with publishing sites is that where you would traditionally create a folder for a type of content in your web site directory, such as a folder for About Us or Press Releases, in SharePoint you create a sub site. We want our end users to see a nice, unified site and not bother them with the finer details that your SharePoint site is actually a collection of nested sub sites under a parent site. The global navigation, also known as the Top Link Bar, is going to help provide that central navigation.

Team sites are meant for focused content and uses. The goal is not to string together a bunch of team sites to create a larger web site. Publishing handles this need instead. That is why the options differ between publishing sites and any team sites that are children versus team sites that stand alone.

Options for stand alone team sites

If publishing isn’t a part of your site hierarchy, then you can do the following with your team site navigation through Site Settings:

  • Add new links
  • Control the order of the links
  • Nest the links under a heading style structure (Quick Launch only)

Options for publishing sites and their children

Here is a list of things you can accomplish using Site Settings for publishing sites and their children sites, whether that child site is a publishing site or not:

  • Inherit the navigation system(s) used from the parent site
  • Automatically show newly added web pages and/or sub sites
  • Control the number of items to display
  • Sort items automatically or manually
  • Add headers, links and control the order
  • Selectively hide sites/pages/links

Looking at the options for publishing sites and their children

Here is a screenshot of the settings you will see when you click into Navigation from the Look and Feel section of Site Settings. Handy stuff has been highlighted in red. And yes, there is a lot of handy stuff here. :)

2013-04-24-SharePointNavigation-02.png

Realistic examples of using the navigation settings

A lot of people turn to third party navigation solutions. Often it is because of a lack of understanding on how to use and apply what SharePoint navigation can do out of the box. Here are some application examples for several of the navigation settings:

  1. Display the same navigation items from the parent site – share a central navigation system across all your sub sites, thus creating the unified user experience and linking all your sites together under one navigation umbrella.
  2. Display the navigation items below the current site – break free of the shared navigation system for a one off site or to reset the navigation for a large network of sites. For example if the Human Resources section of your large Intranet needs it’s own navigation system, it can have a link back to Home but have it’s own HR navigation going across the top that is then shared for all the HR sites and pages.
  3. Option to Show Pages – every time a new product page, biography page, client information page, press release, etc. is added to the site the page will automatically be added to the navigation (likely in a drop down menu based on your structure). It is security trimmed so only users with access to the page will see the navigation item.
  4. Option to Show Sites – every time a new client management, project management, department (or the like) site is created it will automatically be added to the nav, and is security trimmed as well.
  5. Set the maximum number of dynamic items to show – stop run away navigation systems with too many options in the top level.
  6. Add a link – include a link to another web site, company resource or common tool. The formatting of this added link will match the rest of the SharePoint navigation system.
  7. Add a Heading – create your own drop downs in the navigation or nested structure in the Quick Launch. Many organizations have a smorgasbord of links they need to include to various affiliates, company tools or shared resources.
  8. Hide an item – Only 14 out of 15 client sites should be displayed to employees. Hide one off items based on need while not affecting how other content is auto added to SharePoint.

Creating drop down menus

Hands down the number one thing I get asked in regards to navigation is "can I have drop down menus?". Yes, you can have drop down navigation in your SharePoint site and it is easy to do. You will have to have ability to edit your master page.

  1. Open your master page using SharePoint Designer or a tool of your choice.
  2. Switch to Code view.
  3. Open up the Find dialog (Ctrl + F or the Find menu) and search for <SharePoint:AspMenu. Go ahead and include the less than sign that way you only get the start of the navigation code tag in your search results. This should get you two results:

<SharePoint:AspMenu ID="TopNavigationMenuV4" Runat="server" EnableViewState="false" DataSourceID="topSiteMap" AccessKey="<%$Resources:wss,navigation_accesskey%>" UseSimpleRendering="true" UseSeparateCss="false" Orientation="Horizontal" StaticDisplayLevels="2" MaximumDynamicDisplayLevels="1" SkipLinkText="" CssClass="s4-tn" />


<SharePoint:AspMenu id="QuickLaunchMenu" runat="server" DataSourceId="QuickLaunchSiteMap" Orientation="Vertical" StaticDisplayLevels="2" ItemWrap="true" MaximumDynamicDisplayLevels="0" StaticSubMenuIndent="0" SkipLinkText="" CssClass="s4-die">

  1. Go to the first search result (double click the result to quickly jump there).
  2. If in SharePoint Designer, open up the Tag Properties pane (View > Task Panes > Tag Properties). There are all sorts of goodies here that you can play with and use to modify the navigation. I want you to focus on MaximumDynamicDisplayLevels. In addition to seeing it in the Tag Properties, it will show up in the code view as well.
  3. The value for MaximumDynamicDisplayLevels controls the number of drop down menus the navigation system displays. If the value is 0, no drop downs. If the value is 1, then one drop down menu. If you have 2 for the value then you get a drop down menu that in turn has a second level. Or another way to look at it, two fly out menus.
  4. Adjust this number to control how many drop down menus you have. Just don’t forget, you have to have content to show content! If you adjust this value and don’t get the expected drop down or fly out menus, they make sure there are pages and sites in place at those levels.

Still need more?

If these settings don’t meet your needs for SharePoint navigation, there are other options. I suggest you start with our Mega Menu series and use a custom list to control your SharePoint navigation.

Create a State Machine Workflow in WSS 3.0 without Using Visual Studio


You may also be interested in: ViewPoint for SharePoint


 

Editor’s note: Contributor Jeremy Woods is a Solutions-oriented Microsoft SharePoint Specialist, Founder and President of the Northern Colorado SharePoint User Group and Member of the Leadership team for the Colorado SharePoint User Group. Follow him @knighteagle

While at a clients I was asked to create a set of workflow’s that would only “fire” when a specific column changed. I knew that SharePoint Workflow cannot fire on specific status changes, so I figured out a different way to make the Workflow work.

Goal: Create a workflow that updates another list based on the selection of a single column within the item.

Restrictions: No Visual Studio Code allowed in the environment, WSS 3.0

Software Used: WSS 3.0, SharePoint Designer 2007

Here is what I did:

Thinking about how I could target a specific column was probably the hardest part of the whole process, until I looked at SharePoint Designer’s Workflow Wizard. Within this wizard, you can actually do a compare of 1 column to another. I started thinking about how I can use this comparing option to see when a user supplied column changes.

  1. Create the list and target a specific column for the comparison
    I created a simple 2 column custom list. It includes Title and Status. The status column is a choice field with Open Resolved and Closed as the options.

     2013-04-19-SharePointStateMachineWorkflow-01.gif

  2. Create the column that will be used to compare values
    Add columns that are Single Lines of Text that the workflow will compare the original against. In this example, I created the column WF – Status

    2013-04-19-SharePointStateMachineWorkflow-02.gif

     2013-04-19-SharePointStateMachineWorkflow-03.gif

  3. Open SharePoint Designer and create a Workflow
    In the workflow designer, create a step that compares the original column to the new column. There will be multiple If Else statements to work through each of the options. Here is a sampling of the Steps:

     

    Step: Issue Status Open

    Conditions: If Status Equals Open
    AND WF – Status IS EMPTY
    Actions: Set WF – Status to Status
    Then Log New Issue Opened
    Conditions: Else If Status Equals Open
    AND WF – Status not equals Status
    Actions: Set WF – Status to Status
    THEN Log Issue Reopened

    Step:
    Issue Status

    Conditions: If WF – Status not equals Status
    Actions: Set WF – Status to Status
    THEN DO STUFF
    THEN Log Issue Status Changed

  4. Run a test – When you change the Status, the WF – Status will change to reflect the current Status. In the actions, you would then add what ever action you want to do when the status changed (send an email, change another

Improve the SharePoint Breadcrumb Navigation


You may also be interested in: Documentation Toolkit for SharePoint


 

Editor’s note: Contributor Marc-André Bilodeau Lamontagne is a .NET developer at Group GSoft. Follow him @forumma

2013-04-09-BreadcrumbNav-01.png

The breadcrumb is the quickest way to know where you are in a site. It’s also the quickest way to navigate to a parent page. Unfortunately, in SharePoint 2010, the breadcrumb is only accessible by a popup in the ribbon. In the default SharePoint 2010 master page, you also have the site title and the page title, but to navigate quickly in the hierarchy of the site, you need more than that.

The first transformation we are going to do is to change the breadcrumb to display all the hierarchy, like the drop down breadcrumb button. To do this, we will need to modify the master page with SharePoint Designer 2010. You can refer to this article to know how to do this. You can also read my series of articles at to learn more about master pages.

To change the breadcrumb, we first need to locate where in the master page code we need to make the change. In the default SharePoint master page (v4.master) you need to change the content inside the content place holder with the ID “PlaceHolderSiteName”. You can find this content place holder on line 307. There is the code you need to change :

Code to delete


<SHAREPOINT:SPLINKBUTTON id=onetidProjectPropertyTitle navigateurl="~site/" runat="server"><SHAREPOINT:PROJECTPROPERTY runat="server" property="Title"></SHAREPOINT:PROJECTPROPERTY></SHAREPOINT:SPLINKBUTTON>

Code to add


<ASP:SITEMAPPATH runat="server" hideinteriorrootnodes="true" rootnodestyle-cssclass="breadcrumbRootNode" currentnodestyle-cssclass="breadcrumbCurrentNode" nodestyle-cssclass="breadcrumbNode" rendercurrentnodeaslink="true" sitemapproviders="SPSiteMapProvider,SPXmlContentMapProvider"> 
</ASP:SITEMAPPATH>

2013-04-09-BreadcrumbNav-02.png
Figure 2 – The default SharePoint 2010 breadcrumb

2013-04-09-BreadcrumbNav-03.png
Figure 3 – Our new breadcrumb

If you have used SharePoint 2007, you’ll recognize the breadcrumb. This is because we are using the same tag as SharePoint 2007.

There are some parameters you can play with to customize your breadcrumb.

Parameter Description   Values

RenderCurrentNodeAsLink

If you want the current node to be a link on which the user can click to return to that page.

  True / False

PathSeparator

The symbol you want to use to separate each node. By default it’s “ > “.

  Any kind of string, no matter
  the length.

PathDirection

You can invert the direction of the path. In my example I have :
Home > First > Second
You can have :
Second < First < Home
By default it’s “RootToCurrent”

  “CurrentToRoot"
  “RootToCurrent”

ParentLevelsDisplayed

You can limit the number of parent level you want to display.

  Integer

NodeStyle-CssClass

The CSS class applied to the Node. You can change the CSS class to use your own class and customize the Node.

  Class name as string

CurrentNodeStyle-CssClass

The CSS class applied to the current node.

  Class name as string

RootNodeStyle-CssClass

The Css class applied to the root node.

  Class name as string

Use an image as separator

Previously we saw that we can use the parameter “PathSeparator” to change the separator between each node. The value of the parameter is a string, but if you want to use an image as separator, you can use the “PathSeparatorTemplate” parameter. Here is an example of how to use this tag taken from MSDN.


<ASP:SITEMAPPATH id=SiteMapPath1 runat="server"> 
  <PATHSEPARATORTEMPLATE> 
    <ASP:IMAGE id=Image1 runat="Server" imageurl="Images/PathSeparatorImage.jpg" width="20"> 
    </ASP:IMAGE></PATHSEPARATORTEMPLATE> 
</ASP:SITEMAPPATH>


What about permission

It’s really nice to have all the nodes displayed in the breadcrumb, but what happens if a user only has permission to access a sub-site? Well unfortunately, the SiteMapPath tag doesn’t look at the permission to render the breadcrumb. That means the user is going to see every node even if he doesn’t have the proper rights to access these pages. If he clicks on a page he can’t access, the security from SharePoint is going to block the user and show the following message.

2013-04-09-BreadcrumbNav-05.png

This was a quick overview on how to change the breadcrumb to display all the nodes. The navigation is easier for a user when he can quickly see where he is.

How to Achieve a Mega Menu Using Out of the Box Navigation in SharePoint 2013 and jQuery


You may also be interested in: Documentation Toolkit for SharePoint


 

Editor’s note: Contributor Paul Hunt is a SharePoint Solutions Architect at Trinity Expert Systems. Follow him @cimares

I was looking at some requirements from a client for their new SharePoint 2013 Intranet, and one that caught my eye was desire to have Feature images on the top navigation.

The requirement was to have a dynamic top navigation, controlled using the SharePoint out of the box navigation settings, but have the ability to add a Feature image and some text to the menu. My first reaction was to think about a custom navigation control in the master page using Tokens in the navigation settings, then I got to thinking, could we do this with JQuery instead?

Here’s a brief mock-up of what they wanted to achieve.

2013-03-18-MegaMenus-01.png

So this weekend I decided to take the matter offline and have a play in my SP2013 development environment and this is what I came up with. If nothing else, it’s a great example of what you can do with some well placed tokens and a little jQuery code!

The first thing I did was take a look at the options available to us in the out of the box navigation, Not much has changed to the navigation interface in recent versions of SharePoint apart from the addition of Managed Metadata base navigation now in 2013. For this example, I’m just using the standard Navigation that forms part of the basic site structure, however there’s no real reason why you couldn’t use the same token based system in the Managed metadata.

2013-03-18-MegaMenus-02.png

In the actual navigation pane, I’ve added some standard links, and then finally a tokenised link that I’ll be using the jQuery to replace.

2013-03-18-MegaMenus-03.png

The real key with what I wanted to achieve is to make it easy for the client to be able to change the data that exists in these Big menus. So if we edit one of the tokenised options, you can see that we’re just using the default out of the box navigation fully.

We place the token in the title field, using the format ~### to denote the start of the token, then a unique identifier for this particular navigation node, and then the closing token identifier ###~. Then the url of the Image that we want to display in the URL field, and then finally the HTML that we want to display in the description field which can include full HTML.

(Note: Audiencing will still work on these menu’s too!)

2013-03-18-MegaMenus-04.png

When we save this back into the navigation, and then display our page, this is the effect we get when we hover over that particular top level node.

2013-03-18-MegaMenus-05.png

So, how did we actually achieve this? The secret is in the jQuery scripts embedded into the master page (In this demo, I’m just using a content editor web part linked to an external html file to make it easy to test and demonstrate!)

I won’t describe the CSS here as it should hopefully be fairly self explanatory and I’ve commented the jQuery code fairly well. I would say that you can and should condense any JavaScript code that you place into your production environment however for demonstration purposes, this code is spaced out and more verbose than I would write for production.. (tldr THIS IS NOT PRODUCTION CODE!)


//First we need to find all of our DOM elements that are in the Top level navigation 
//and contain the start of the token field. 
$("UL.dynamic span.menu-item-text:contains('~###')").each(function(){ 
  
//We then extract the token identifier, removing the ~### and ###~ from either side 
var menuItem = $(this); 
var parentMenuA = menuItem.closest("a"); 
var parentMenuUL = menuItem.closest('UL.dynamic'); 
var menuToken = menuItem.text().replace('~###','').replace('###~',''); 
  
//Then we extract the link to the image, and to the description field (Held in the title attribute) 
var imageUrlHREF = parentMenuA.attr("href"); 
var linkUrlText = parentMenuA.attr("title"); 
  
//Then we hide the tokenised menu item as the user doesn't need to see it. 
menuItem.hide(); 
  
//Now we add an extra class to the Parent UL to apply some CSS 
parentMenuUL.addClass('featuredNavigation'); 
  
//And then wrap the original contents of the menu in an extra div to make styling them into the top right hand corner easier 
parentMenuUL.wrapInner("<div class='navItemsWrapper'/>").wrapInner("<div class='navWrapper' id='" + menuToken +  "'></div>"); 
  
//Finally we build the Featured image with the data from the navigation item 
var imageDiv = "<div class='navWrapperImageDiv'><img class='navWrapperImage' src='" + imageUrlHREF + "' alt='Featured Image'></img>" + 
    "<div class='navWrapperImageText'>" + linkUrlText + "</div></div>"; 
  
//And then inject it into the top of the navigation object using the prepend instruction. 
$('#' + menuToken).prepend(imageDiv); 
});

That’s all the javascript there, though you can download the entire html file that I created for testing and embed it into a SharePoint page using a CEWP to see it in action in your environment.

Navtokeniser.html script file. (Rename from .txt)

I hope it sparked some ideas.

Paul.