I have decided to go with customizing the Sharepoint web parts. I am using CMS 7.0, so I copied the contents of the CMSWebParts\Sharepoint directory to a company specific folder under CMSWebParts and renamed all the class in the copied files to include a company identifier to prevent conflicts. Then in the CMSWebParts\{company}\Sharepoint\SharePointDataSource_Files, I updated the logic in the SharePointDataSource.ascx.cs. I added a new public property to hold QueryOptions
private string mQueryOptions;
/// <summary>
/// Gets or sets query options which should be used. XML Formatted.
/// </summary>
public string QueryOptions
{
get
{
return mQueryOptions;
}
set
{
mQueryOptions = value;
}
}
and updated the LoadListItems function to populate Query Options.
if (!String.IsNullOrEmpty(QueryOptions))
{
queryOptions = new XmlDocument();
string xml = "<QueryOptions>";
xml += QueryOptions;
xml += "</QueryOptions>";
queryOptions.LoadXml(xml);
}
The queryOptions parameter was already being passed to the GetListItems method of the SharePoint web service.
Then I registered my WebParts through CMSSiteManager by cloning the existing Sharepoint controls into a Company specific category and updating the control paths. Then added the new field to each of them for Query Options under the advance category. I opted for the same configuration as what was used for the Query field.
After that, it was a matter of adding the web part to the page and configuring it. If I wanted to pull contents from a specific folder, I added the folder path into the QueryOptions property. This includes the necessary sub sites and list code name:
<Folder>{SubSite}/{ListName}/{Folder}/{SubFolder}</Folder>
I did have a few issues when I tried to configure the webpart on my page to allow drill down capability. Instead of hardcoding a path in the Query Options property on my page, I used macros to generate it based on a query string.
{%if (QueryString.GetValue("folder")!="") {"<Folder>"}%}
I used both the urlencode and replace macro options because the urlencode translated a space into plus ("+"). SharePoint expects them to be a "%20" instead. Also, if I tried to build this all inside of a single "if" statement, the replace macro options replaced the plus "+" with more than just a "%20". It actually included the closing brackets from my macro's if statement. My solution was to split it up into 3 if statements, one for the opening Folder tag, one for the path, and one for the closing Folder tag.
One other issue I ran into with the drill down was caching. I had left the caching properties set to the default. When I tested the drill down of my page through preview, it worked fine. But when I did it though the live site, it wouldn't drill down even through the query string was different. I discovered that I had to set the cache minutes to 0 in order to force it to retrieve the sub folder information from SharePoint.