SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was wondering if it is possible to somehow create a new itemstyle which has a link to the library where the items in the content query is located?


  1. First ListItem
  2. Second ListItem
  3. Third ListItem
  4. Fourth ListItem
  5. Fifth ListItem

View all items <-- this being the link to the library

Is this possible?

share|improve this question
up vote 3 down vote accepted

Just add the anchor tag with a dynamic link to the bottom of your itemstyle xsl and then wrap it with an xsl:if statement to check the position to see if the last list item is last.

<xsl:if test="position() =last()">
   <a href="link.aspx">View all items</a>

If you want to make the href dynamic, find a source for the link in your XML somewhere and use:

<a href="{@source}">View all items</a>

You may have to use XSL to remove formatting after a certain character to achieve the path to the libary from another link

share|improve this answer
It doesn't work - position() is always the same (1) for all returned items. I put the snippet in the end of my ItemStyle.xsl template. – tarjeieo Dec 6 '11 at 10:56
Had to use this method to get it to work… – tarjeieo Dec 6 '11 at 12:54

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.