Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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?

Example:

  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
add comment

1 Answer 1

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>
</xsl:if>

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 blog.mastykarz.nl/… –  tarjeieo Dec 6 '11 at 12:54
add comment

Your Answer

 
discard

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.