It was requested from me to make a page in MOSS that will display Departments in an organization, and there is a set of sub departments and in each sub department there may be another group of sub departments and then a list of file library that may also be divided into groups.
I want to save all these files in only one document library but divide them into folders and subfolders as required, and make the minimum number of pages and code to display these folders and items and without any .net coding.So my solution is to make a page in SharePoint designer and add a DataSource and a DataView then make the following steps:
1. In the SPDataSource add Scope="RecursiveAll" this will make the datasource get all the items (folders and documents) not just the folders in the first level.
2. Add parameter to the DataView, ex. Name: FolderPath, Source: QueryString, QueryStringVariable: FolderPath, DefaultValue: En/DownloadCenter/Documents (which is the path to your document library)
3. Make a filter in the DataView to have Path, Equals, [FolderPath]
4. Make a variable to be used as the page link or the document link as:
<xsl:variable name="url">
<xsl:choose>
<xsl:when test="@ContentType = 'Folder'">documents.aspx?FolderPath=<xsl:value-of select="substring(@FileRef, 2)">
</xsl:value-of>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@FileRef"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
5. The above code will check if the item is a folder so we will need the link to redirect to the same page (documents.aspx in our case), and if the item is a document so we need to redirect to the document URL.
6. substring(@FileRef, 2) is used to remove the first / character in the URL Path (not the Path), to know what is the difference between both, Path: En/DownloadCenter/Documents, URL Path: /En/DownloadCenter/Documents/Subfolder1
No comments:
Post a Comment