31 October 2012

Links to Documents in DVWP with Linked Sources

I received a request from a co-worker today to create an aggregated view of multiple document libraries within a root site collection's sub-sites at the top-most site collection level. The request seemed pretty straight forward and I immediately went off to start creating a Data View Web Part.

I first created four individual SOAP connections through SharePoint Designer for each of the document libraries on the four sub-sites. I then used the Linked Sources option to combine all of the SOAP connections into one larger connection that could be dropped into an empty data view.

All went well with creating this linked source and I was able to display the information grouped by the document's source location. I went ahead and switched the  Document Title to a hyperlink, in hopes to use the "URL_path" column as a means of linking directly to the document, so that even at the top-level site collection where this aggregated library lives, users would be able to click on the title of the document and open it.

I found however, that this column was not available to me. I did find that the @ows_FileRef column was available, which links to the relative URL of the document (i.e. - /sites/sub-siteName/document1.docx). I went ahead and cleared out the {@FileRef} hyperlink at the bottom of the hyperlink options screen and replaced it with "http://myservername/{@FileRef} assuming that this would take append the relative location of my file to the server name, creating a full path to the file - right?

Yes and no.

It created the URL just as I wanted it, but I found that right before the relative /sites/subsiteName/ URL, there were a few extra characters; "3;#". I started perusing the web and found that there were some other instances of similar things happening, but the characters being slightly different; maybe "1;#" or "2;#", etc.

Thanks to the web, I found that you could go into the actual code view and create a new XSL variable and fix the URL.



As you can see from the code above, we are taking the default table row and before creating the hyperlink to the document, creating a new variable entitled "DocURLtemp". You can see from the "select="substring-after" attribute that we are creating a copy of the "ows_FileRef" variable, but only after the "#" symbol (remember, we liked the relative URL that the FileRef variable provided us, but wanted to exclude the erroneous "3;#" that came before it - so this attribute is taking a copy of the FileRef variable but excludes those erroneous characters).




So with that new variable declared, we can now tweak our proceeding URL to include our server URL and then include the new variable we created.

Now after making these changes and saving your page, your document titles should link directly to their respective files!

-Steve


10 May 2012

Styling Individual Link Headers in the SharePoint 2010 Quicklaunch

I had a client reach out to my the other day hoping to highlight a specific link header in their Quicklaunch navigation of their SharePoint 2010 Intranet homepage. Modifying all of the headers is fairly straight-forward, but I haven't seen any documentation that calls out how to change the look and feel of one specific header. For my client, he wanted to change an "Emergency Contact" link to red to make it a little more visible to his end users.

After some tinkering, I realized that you could a modification to the first-child selector to call out the specific link. In this code below, our "Emergency Contact" link was the second link header (the first "li" item after the first-child selector). If your link header is the third or fourth in the Quicklaunch, all you need to do is add a subsequent "+li" or "+li +li" to select the applicable link.

/***Single Link Header Customization***/
.menu-vertical > ul.root > li.static:first-child +li {
font-weight: bold;
padding:1px 1px 1px 0px!important;
color:red!important;
}
/***End Single Link Header Customization***/
Hope this helps someone out there. 

-Steve

02 May 2012

How to resolve a disappearing site logo on web part pages

I was implementing a solution for a client the other day that required the use of a web part page. Specifically, I was using a web part page as part of a custom "Welcome" page for a Help Desk ticket application. I set the custom welcome.aspx web part page as the landing page and specified the URL of a site logo.

I found that upon page load, I could see the site logo that I specified through the Title, Description, and Icon settings but after a split second the logo would revert to the default, orange SharePoint site logo. Navigating to any other page within the site would display the correct logo, just not my custom web part page.

The fix lies in the "Title Bar Properties" settings from within the "Edit" ribbon. Go into Edit Mode, click on "Title Bar Properties" and specify the URL of the site logo from within the proceeding pane. It seems odd that this step is required, considering the URL is already specified from within Site Settings, but nonetheless this is the workaround.

-Steve