Monday, December 20, 2010

Disable opening of site in SharePoint Designer



Steps to disable use of designer:


1)  In the site template's onet.xml in the 12 hive (site templates folder), include the tag attribute - “DisableWebDesignFeatures=wdfopensite” in the first tag of the file, after the title attribute and save the file.
2)   Open Central Administration, click Application Management tab.  Click User Permissions for Web Application, and make sure the option to "Add and customize pages" is unchecked.
3)   Recycle the application pool for the web application or do an IISRESET.

After these steps the designer is disabled.

To enable back, just undo the steps 1-2 mentioned above and recycle the app pool or IISRESET.


SharePoint Edit page URL - querystring parameters

Open a listform page in edit mode without using designer!!

One day got a request to add a webpart in the Newform.aspx of a list. Generally, to add webparts to pages that cannot be edited through the browser, the approach generally followed is to edit the page in designer and add a webpart zone and add the webpart.

But unfortunately i didn't have access to the designer and needed to add the webpart urgently. So found a workaround, maybe not a neat solution, but it works!

Using the SharePoint querystring parameters, we can go to the edit mode of the Newform.aspx through browser. 

So to enter the edit mode, i gave the below URL
newForm.aspx?ToolPaneView=2&PageView=Shared
This opened the page in the edit mode, and i was able to add the webpart.

Drawback - We cannot add webpart zones if layout changes are needed; we need to resort to designer for that :)

Other useful querystring options:
QueryString
Operation
ToolPaneView=2
Can browse and add webparts
ToolPaneView=3
Can search and add webparts
Mode=edit
Edit mode
Mode=view
View mode
PageView=Shared
Shared mode
PageView=Personal
Personal mode
Contents=1
Opens webpart maintenance page – can add or delete webpart on a page

Sunday, December 19, 2010

SharePoint Themes in WSS 3.0 - some tips

While working on the intranet portal for my client using WSS 3.0, we came across situations where the client web redesign was happening frequently and we had to change the theme accordingly. We had 30 + site collections and total of 120 sub-sites in all… This count would increase to double within a year or so!
Whenever redesigned, we had to apply it for all the sites!

The approach we had followed was to have a master page and theme, which would suffice our User Experience needs.

A feature scoped at site collection was created and activating this feature would set the custom master as the default master to the root site and all its sub-sites. Referred this post to implement this - http://blogs.msdn.com/b/navdeepm/archive/2008/05/04/changing-masterpage-programmatically-for-site-collection-and-sub-sites.aspx

Coming to setting the site theme similar to the master page. Setting theme at each sub-site level is a tedious job :). So we came up with a feature similar to the above, which would set the custom theme for all the webs in the site collection.

Programmatically setting theme

SPSite site = new SPSite("");
SPWeb web = site.OpenWeb();
web.ApplyTheme("");


So in the feature activated code of the feature receiver, the above code was used to set the theme.

Now the issue that we faced due to our requirement for frequently changing of design/theme, even though the SharePoint theme files are stored in the 12 hive, once a theme is applied, SharePoint stores a copy of the css file (theme file) in the content database: 
(the link to the file is as something below)

"/_themes/Intranet/cust1011-65001.css"

So if you update the theme file in the 12 hive, the same doesn't get refreshed until we apply the theme again. i.e. in our case activate and deactivate the feature to set theme.
So the alternative we developed was to use a custom css file, the link to which goes from the theme css file.

Details:
In the theme.css file in the theme folder, instead of giving all the css styles, we gave a link to the custom css file, placed in the layouts folder. Ex: @import url ('/_layouts/customtheme.css');
So now our theme files in turn points to the customtheme.css file.
Even though SharePoint still refers to cust1011-65001.css, in turn it will be getting the css styles from our customtheme.css.

Whenever the new theme is created, we just needed to upgrade the customtheme.css and automatically the new styles would reflect on all the sites. Because the theme css is in turn referring to the custom theme file in 12 hive!

SharePoint User Information List - findings

SharePoint stores the details of the users (like DisplayName, Account ID, picture, email etc.) added to the site in a hidden list - User Information list. This hidden list is accessible by the administrators only.

The URL to access this list is:
http://sitename/_catalogs/users/detail.aspx - Shows the detail view of only Users in the list.
http://sitename/_catalogs/users/simple.aspx - Shows the simple view of only Users in the List
http://sitename/_catalogs/users/allgroups.aspx - Shows all the groups without users available in Site.

The list can be accessed programmatically by the property SPWeb. SiteUserInfoList.  Say if we need to capture user’s hobbies or any other details, a new column can be created in the list and can be updated programmatically.

Note:
1       This list is not indexed by the crawler; hence users cannot be searched in the site. The people search in MOSS searches the User Profiles imported through SSP. Since there is no user profiles concept in WSS 3.0, out of the box, there is no people/user search option.