Put MySite link of creator in CQWP using itemstyle.xsl

This will show you how to correctly link the creator of an item to their mysite in a Content Query WebPart.

Step 1:
Declare the variable “authormysite” and the author string of “UserLookup”. We pull the “Login” parameter, because the username is what is appended on the mysite link out of the box.

<xsl:variable name="authormysite">
<xsl:value-of select="ddwrt:UserLookup(string(@Author) ,'Login')" />
</xsl:variable>

Step 2:
Create the link to the mysite page, appending the new variable’s value that you just created.

< a href="https://m.isb.bj.edu.cn/Person.aspx?accountname={$authormysite}" ></ a>

Step 3:
Within the link, you want to declare the value of @Author to get their full display name.

<xsl:value-of select="@Author" />

Final code:

<xsl:template name="mysitelink" match="Row[@Style='mysitelink']" mode="itemstyle">
<xsl:variable name="authormysite">
<xsl:value-of select="ddwrt:UserLookup(string(@Author) ,'Login')" />
</xsl:variable>

< a href="https://m.isb.bj.edu.cn/Person.aspx?accountname={$authormysite}">
<xsl:value-of select="@Author" />
</ a>

</xsl:template>

Use a friendly URL in a Sharepoint list display

Is your URL waaaaaaaaay too long for your display form (usually dispform.aspx) in Sharepoint 2010? This is an easy fix.

Step 1:
Create a new display form for your list item in Sharepoint Designer

Step 2:
Find your URL field. My URL is a link to the mysite of a person.

Step 3:
Create a new variable, wrapping what is currently there as your xsl item.

So in my case, I replaced this:

<xsl:value-of select="@MySiteLink"/>

with this:

<xsl:variable name="linktomysite">
  <xsl:value-of select="@MySiteLink"/>
</xsl>

Step 4:
Finally, call the variable in a nice short, user-friendly link

< a href="{$linktomysite}">MySite Profile</ a>

Include the Site Name in your CQWP

Step 1
Create your CQWP (Content Query Webpart) rolling up whatever you’re planning on rolling up, and then export it to your desktop. Edit it in notepad++, textwrangler, whatever texteditor you use.

Step 2
Find the “ViewFieldsOverride” property and replace it with the following:

<property name="ViewFieldsOverride" type="string"><![CDATA[<ProjectProperty Name="Title" />]]></property>

Save the file as “sitename.WebPart” and import it into your page, insert into a webpart zone, and you are ready to style the XSL.

Step 3
In your ItemStyle.xsl template declare the following:

<xsl:value-of select="@ProjectProperty.Title" />

Step 4
Go back in and edit the webpart…you should see that now there is a field called “ProjectProperty.Title”, leave it blank, it’ll take care of itself.

That’s it!

Thanks to this site for most of the solution.

Remove Checkboxes from XSLTListViewWebpart in Sharepoint Designer

I had this problem where checkboxes were appearing on a list I placed as a webpart in Sharepoint Designer. The list view itself is set to not show checkboxes, but it was still appearing! So here’s the fix.

Step 1

Go to Sharepoint Designer, click on your webpart, then under “List View Tools” in the ribbon, click “Design”, then select “Customize XSLT > Customize Entire View”

Step 2

Look for <View and add the parameter: TabularView=”False”

That’s it. I found this solution on this site, thanks!

Formatting a Date in a Content Query Web Part

Finally! For hours I’ve been trying to format a date in the CQWP, and now I’ve finally figured it out. A lot of blogs and help articles suggested using msxsl: functions and ddwrt functions, but in the end, it was this that worked:
<xsl:value-of select=”ddwrt:FormatDateTime(string(@Date),1033,’dddd, MMM dd’)” />

If you just plop this inside a new item style inside of itemstyle.xls it should end up displaying great!
Oh, and add this in your tag at the top of the page:
xmlns:ddwrt=”http://schemas.microsoft.com/WebParts/v2/DataView/runtime”
Woooohooo!!!