A customer asked me if they could add a "Add Folder" to the document library list type in SharePoint 2010. I said, "probably", but wasn't sure exactly how one might do it. I dug in and found it! The secret lies in the vwstyles.xsl file. It is located in:
C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions14TEMPLATELAYOUTSXSL
You will want to open the file and find the template called:
<xsl:template name="Freeform">
From there you should see some XSLT that is responsible for creating the "Add document" link. Right above the variable declaraton"<xsl:variable name="Url">", you need to add a new one:
<xsl:variable name="FolderUrl">
<xsl:value-of select="$HttpVDir"/>/<xsl:value-of select="$XmlDefinition/List/@title"/>/Forms/Upload.aspx?Type=1&IsDlg=1&List=<xsl:value-of select="$List"/>&RootFolder=<xsl:value-of select="$XmlDefinition/List/@RootFolder"/>
</xsl:variable>
Then add a new table row below the current one that defines the "Add Document" link:
<tr>
<td class="ms-addnew" style=’padding-bottom: 3px’>
<span style=’height:10px;width:10px;position:relative;display:inline-block;overflow:hidden;’ class=’s4-clust’><img src=’/_layouts/images/fgimg.png’ alt=” style=’left:-0px !important;top:-128px !important;position:absolute;’ /></span>
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes">&nbsp;</xsl:text>
<xsl:choose>
<xsl:when test="List/@TemplateType = '115'">
<a class="ms-addnew" id="{$ID}-{$WPQ}"
href="{$Url}"
onclick="javascript:NewItem2(event, "{$Url}");javascript:return false;"
target="_self">
<xsl:value-of select="$AddNewText" />
</a>
</xsl:when>
<xsl:otherwise>
<a class="ms-addnew" id="{$ID}Folder"
href="{$FolderUrl}"
onclick="javascript:NewItem2(event, "{$FolderUrl}");javascript:return false;"
target="_self">Add folder
</a>
</xsl:otherwise>
</xsl:choose>
</td>
</tr>
BAM! You now have a handly "Add folder" link at the bottom of the page instead of using the ribbon. NOTE: This change would need to be applied to all WFEs in the farm and you would need to re-check after every CU or Service Pack deployed. Also, you will need to add some other logic to keep it from showing up in places you don't want it…I'll have to add this in a later update to this blog.
NOTE: Also keep in mind that this file is cached on its first load and an IISRESET is required in order to see any changes.
Enjoy!
Chris