Search code examples
sharepointxsltdocument-library

How to obtain document library name from the URL


How to obtain document library name from the URL cqwp. For example,

http:///sites/site1/DocLib/Forms/AllItems.aspx

I know there is substring function with xsl

<xsl:param name="DocLibName"> 
  select=substring(url) or whatever the code should be
</xsl:param>

Solution

    1. Some good Links.

    http://msdn.microsoft.com/en-us/library/dd583143(office.11).aspx

    1. Add these two line

    <xsl:variable name="DocLibName" select="substring-before(substring-after($PageUrl, '/Forms/'), '/')" />

    <xsl:param name="PageUrl"/>

    1. set VIEWFLAG=1 (it should be in the properties windows)

    2. Find this line and modify if you want Filter the webpart list

    <xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row" />

    Change it to following

    <xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row[(@CustomerNo=$DocLibName)]"/>

    You can use this to display

    <xsl:value-of select="$DocLibName"> <br/>

    <xsl:value-of select="$PageUrl"/><br/>