Thursday, May 28, 2009

Customize "Welcome UserName" control in SharePoint

This article describes how we can customize "Welcome UserName" control in SharePoint.
To add a new menuitem.

create a feature that looks this (first part being the feature.xml and the second being the elements.xml) :









Feature Installation and Uninstallation
Although the best way to install a Feature is through a Solution, you can do it manually. Just keep in mind that you must do it in all the servers of the farm (whereas with the Solution, the multi-server deployment is automatically assured).
To install a Feature you have to create a folder in C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES with the name of the Feature and copy the feature.xml and any other files (like Element Manifests) to that folder. Then you have to execute the following console command:
stsadm -o installfeature -name MyFolderName
Where MyFolderName is the name you gave the folder that contains the Feature.
To uninstall the Feature you have to execute the opposite console command (see below) and remove the folder you created.
stsadm -o uninstallfeature -name MyFolderName
Feature Activation
Similarly, besides activating and deactivating the Feature using the SharePoint UI, you can do it using console commands. To activate a Feature you have to execute the following command:
stsadm -o activatefeature -name MyFolderName -url http://MyServer/MyWebSite
Where MyFolderName is the name of the folder that contains the Feature, and http://MyServer/MyWebSite is the URL address of the web site where you want to activate the Feature.



like this --:)

Wednesday, May 20, 2009

How to remove Site Actions and View All Site Content

please try not to modify default.master page use custom one.
Removing Site Actions: Open your master page in any editor like Visual studio (recommended) or notepad.Find “SharePoint:SiteActions”.If you opened it in Visual studio toggle the Site Action Control.

Check the screen shot.








Now add SharePoint:SPSecurityTrimmedControl control just before the SharePoint:SiteActions control

Check the screen shot.








Here is the text to add<>Now here is the description what we had done.SPSecurityTrimmedControl as the name suggest, the control check the SharePoint permission and if user is permitted (if the user have permission) then it will access the content inside this control.And if the user don’t have a permission then the content inside this control will not been accessed.PermissionsString attribute define which set of permission can access the control.You can give multiple permission by “,” (comma).This “,” will work as OR condition to the permission set.To check the permission set Enumeration check this link of MSDN There is no other way to hide this buttons but we can do like this way.Chose a permission from above msdn link like ManagePermissions or ManageWeb or DeleteVersions the permission that your user don’t have.And set it in master page.Because our basic requirement is the END user should not see “Site Actions” and our END user must not have at least one permission from the permission list. Even contributor does not have all the permission.So you are done by doing this you can remove site actions for non admin users without coding.Removing View All Site Content:Find “~site/_layouts/viewlsts.aspx” in the master page.You will find Sharepoint:SPSecurityTrimmedControl is already there but the PermissionsString attribute is set as “ViewFormPages”.Which means that if a person have view rights in the form pages then that person can see this link.You can also change PermissionsString to high permission like ManageSubwebs or ManagePermissions or something like that so that this link will also be removed if the login user don’t have permission mentioned in permissionstring.

Monday, May 18, 2009

Change the Welcome page

Applies to: Microsoft Office SharePoint Server 2007
To change the Welcome page of a site, do the following:
1. On the Site Actions menu
, point to Site Settings, and then click Modify All Site Settings.
Note If no menu appears when you point to Site Settings, click Site Settings to open the Site Settings page.

1. On the Site Settings page, under Look and Feel, click Welcome page.
2. In the Welcome Page section, click Browse to find the Welcome Page that you want to use for the site, and then double-click the item to select it.
3. Click OK.

Unable to delete Master Pages or Page Layouts?

I have just been tidying up my masterpage library in a WCM sitecollection and came across an issue when trying to delete some master pages.

When trying to delete I got the following error:





I know that this is not the case - no other pages use this master page!

Fortunatley there is a workaround for this. Simply create another folder in the masterpage folder and then drag the master page you want to delete into it. Then delete the folder and your master page is gone.

Thursday, May 14, 2009

Master Pages vs. Themes

Over the last few months I have heard a lot of confusion and question about if a site should use a master page or a theme. In this post I am going to go through some basic pros and cons and information to help you make a better decision as to how to brand your SharePoint 2007 site.
The first thing I recommend is to assess your design needs. Set aside terminology and SharePoint features and don't worry about how to execute the site branding, but identify what you need to change from the default SharePoint look and feel. Here are some questions to ask:
1. Do you need to change the colors used? For example change the blue palette to another color palette? Often you need to incorporate corporate colors, product color schemes or colors that better reflect a mood/emotion or industry you are in.
2. Do you need to change the images used? Do you need to incorporate certain illustrations, photos or logos? Most everyone at a minimum wants to include their own logo. Do you need to style a header that matches your branding?
3. What navigation do you want to use? Do you want to use both the tabbed horizontal menu and the left navigation, or maybe only one or neither? If using the menu(s), do you need to alter how they look? If so, how drastically?
4. Do you need to move core components of the page layout around? Don't think about content, but about the page wrapper (header, nav, footer). Are there other components you need to incorporate, move or remove?
5. Do you plan on having a collection of sites and each site needs to have its own color palette? Some sites have sub sites (such as HR, travel and accounting in an Intranet) color coded.

After making some decisions about your design, you can start looking at what master pages and themes can provide and you can start to decide which is best for the site.
Master pages provide total control of the site layout. Themes on the other hand re-skin the layout by changing colors and images used in the design. Since a theme is just a CSS file and images, the layout of the page such as the location of the navigation, can't be altered.
If you are using the SharePoint site intact with the navigation that comes with the site, and you just need to update the colors and images and add a header to the site, a theme can handle all of that for you. To see what a theme can change, apply one of the many out of the box themes that SharePoint provides.But testing out a SharePoint theme doesn't give you a full idea of what you can do with a theme. The page icon next to the title can be removed, so can the title. Header images can be added in. People often think themes can only update the colors used since that is what the out of the box themes do. But a lot more can be accomplished.
A benefit to themes is that when you apply a theme, it also affects the pages in the _layouts directory, whereas master pages do not.
If a theme doesn't seem to fit the bill for the design you need to implement in the SharePoint site, then look to master pages. With master pages you can implement your own navigation systems, custom code and design elements, move elements around on the page or hide SharePoint components you don't want to use. It is a more complete solution for totaling changing the way SharePoint looks.
In some situations, both master pages and themes can be used. If you use a master page to style the site, using a custom theme can style the _layouts pages to coordinate with the look of the site. If you need to apply different color palettes for one design for sub sites, in MOSS use can use the alternate CSS setting, but that isn't available for WSS sites. You can create a custom master page for the WSS sites to use, then create and apply different themes to change the color palette of sub sites.
One drawback to a theme is that you have to apply it at the site level for each site. Master pages on the other hand can be inherited (for MOSS sites) through sub sites. But this is buggy and more than likely you have to apply the custom master page on each site anyways. Another possible drawback to themes is they have to be installed on the server thus making them available to all sites in the farm. But there is a way around this if you don't have access to your server or if you don't want a theme available to all sites.
You can apply a theme (pick one that most closely resembles what you want to ultimately do with your site design) to your site, and then a copy of the theme CSS file will be created for the site. You can edit this file in SharePoint Designer (thus creating a copy of it in the content database and customizing the file) and create your customizations for your site.
So, to run down some key points:
Master Pages
· Can totally change the look of a site.
· Can hide SharePoint components that you don't want to use.
· Will allow you to alter the layout of the page, in addition to changing the colors and images used in the site.
· Will not affect _layouts pages. You will need to use a workaround.
Themes
· Can re-skin the layout of a site to use different images and colors.
· Can only hide SharePoint components that can be controlled through hiding it in the CSS (display: none set on a class/ID).
· Affects _layouts pages.
· Can be used as an alternate CSS file application method, similar to alternate CSS setting in MOSS sites.
· Are installed on the web server unless you customize the file.

Wednesday, May 13, 2009

SharePoint 2007 Design Tip: Import your CSS for SharePoint Themes

Import your CSS for SharePoint Themes
One of the major drawbacks of SharePoint themes is you have to reapply the theme to any site that uses your custom theme in order to see any new changes that you have made. This happens because when you apply a theme to a SharePoint site, a copy of the theme is added for the site in the content database.
Try it out, open a test site in SharePoint Designer and look at the folder structure in the Folder List task pane. If you have already applied a theme to this site, you will see a_themefolder. If you have not applied a theme to this site, then this folder will not appear. Expand the folder and you will see a single sub folder named the same as your theme. Now go and change the theme the site uses through a browser. Return to SharePoint Designer and hitF5to refresh the Folder List. The_themefolder will appear if you didn't have a theme applied the first time, and the sub folder under this directory will change to reflect the theme you just applied.
When you make a change to the theme files on the web server, it does not update any copies of the theme that live in the content database. When you apply a new theme in the browser, it replaces the copy in the content database with a new theme. That is why you have to physically reapply a theme when you make changes, you have to replace the theme copy in the content database.
From a development perspective, the theme copy in the content database is rather handy. If you update any of the files in the content database (by changing the CSS files in SharePoint Designer and importing in new images), the changes automatically appear in the browser. Woo-hoo! This just made life easier when it comes to developing themes.
But after you finish up development, you are stuck back with the problem of how to update your theme in the future, especially if it is applied to several sites. This is where this trick comes in.

Import CSS to Create Editable Themes
Create a copy of the finaltheme.cssfile and store it in another location on the web server, such as:C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\1033\STYLES\YOURCUSTOMFOLDERHEREYou can even rename the file, it no longer needs to be named theme.css.
Open the originaltheme.cssfile in the custom theme folder, delete out all of the contents, and add an import rule for your new CSS file:@import "/_layouts/1033/styles/YOURCUSTOMFOLDERHERE/theme.css";
Save the file and deploy your theme (add text to SPTHEMES.xml and reset IIS). Apply your new theme to the site. Now go to the new CSS file in the Styles folder and make a change. Refresh your browser. Your change will appear. That is cool.
By moving around your files and using the import rule you can create a theme that you can update without reapplying the theme to every site that uses it. Be sure to update your image paths in your CSS styles to a location where you can edit the images as well, such as:C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\IMAGES\YOURCUSTOMFOLDERHERE

Tuesday, May 12, 2009

Custom Site Master Page, Theme and Feature for SharePoint 2007 (MOSS 2007) and WSS 3.0

Custom Site Master Page for SharePoint 2007 (MOSS 2007) and WSS 3.0

Master Pages, Page Layout and Content Place holder
(This is a large topic in itself, but I will try and cover it quickly.)
Master Page: A master page in a Share Point site defines the outer frame of each Web page. It determine the look and feel of the site. It contains the features, such as navigation links, that we want all pages in our site to share, and it provides a single place to control all of those features. Typically, a site uses a single master page, although large Internet sites might use more. For example, a corporate Web site that is used to publicize more than one product could use separate master pages so that the content for each product is properly branded. A master page is an ASP.NET file with the extension .master.There are two types of master pages: site master pages and system master pages. The site master page is used on published Web pages in the site. It is the master page that site users and visitors see when they view published content. The system master page supplies the layout of pages in the site that implement the user interface for commands —for example, Document Library Settings.
Page Layout: A layout page is an Active Server Page Extension (ASPX) page that defines a layout for a type of content page. When a SharePoint site user opens a page in a browser, that page's associated layout page is first combined with the active master page, which supplies the outer frame of the page, and then the contents of the page are rendered in the fields (called field controls) on the layout.We design layout pages to match the contents of a type of content page. For example, if a content page type has two images, the associated layout page should have fields in which to display both images. We can design multiple layout pages for the same content page. For example, for a page with an image, we may have one "image left" layout page and one "image right" layout page.
Content Place holder: The other core component that is used in a master page file are the Content Placeholders. A Content Placeholder is just that, a location flagged as where content will be inserted. The content is stored in the page layouts. The content placeholders designate where the content from the page layout will be inserted in the master page.Content Placeholders can be wrapped in HTML code, for example DIV, SPAN or TABLE tags. A good way to think about it is everywhere we would place content that we would like to have customized for each page, insert a Content Placeholder.








Type of Master Pages

There are 3 main types of Master Pages in SharePoint:
1.Site Master Pages
2.System Master Pages
3.Application Master Pages

Site master pages are usually used in SharePoint publishing site definitions, but they can be used for any SharePoint version. These pages are used so the main page can have one master page while the subpages and views use other master pages (example of a subpage is a view of a list or library). This is needed for publishing pages because the main page, of a site or subsite, usually has the publishing feature turned on while the other pages don’t. These publishing UI functionalities are contained in the master page, thus you need a separation of master pages between the main page and the subpages.
This technique is not specific to publishing pages. A good example of this is the meeting workspace site in MOSS. This site definition is not a publishing site. However the main page is different than the subpages. This is accomplished by making the main page a site master page.
Site master pages are defined by ~masterurl/custom.master in the content page declaration.

System master pages are used for most non-publishing sites and subpages in publishing sites. The system master page is what you typically see when you go to a WSS site or a non-publishing MOSS site.System master pages are defined by ~masterurl/default.master in the content page declaration.
Application master pages are for all “Layout” pages. Layout pages are SharePoint administrative pages that are typically seen when doing site administration. You can tell a layout page because the URL of the site has _layout in it. Layout pages are static, file server pages that are not driven by the database like other pages in SharePoint. We will discuss application pages in more detail in article 5 of this series because of the difficulties involved in understanding and customizing them.
Application master pages can be found at: %Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS.

Create a Feature: Add Custom Master Pages to your Site Collections
  1. Navigate to the Features directory on your web server: Local Drive:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES
  2. Locate the PublishingLayouts Feature directory. Copy this folder and paste it at the root of Features. Rename the folder to a unique name of your choice. For my example I used CustomMasterPages.














3. Open your new Feature directory. At this point you can leave all the default folders, or you can choose to clear out what you don't want to use. You only have to keep Feature.xml and ProvisionedFiles.xml. To create a clean file set, at a minimum clear out the contents of each sub folder in the directory (en-us (or your language), Images, MasterPages, PageLayouts, Styles).
4. To start, we need at least one master page file in the Feature folder. You can copy one of the existing master pages, paste the copy in the directory, and rename the copy to your unique name, or alternately paste in your custom master page, or create a new blank file with the extension of .master.















5. Next, open the ProvisionedFiles.xml file in Notepad or a similar editing application. Local Drive:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\YourFeature
6. We are going to delete out all of the content and only keep the OSGMasterPages Module tag and the PublishingLayoutsPreviewImages Module tag. As opposed to listing out what to strip out, here is the code you need in this file:
7. Update the properties to reflect the new master page details:

a. Change the URL to your custom master page.:
b. Change the Preview Images to a custom image:Add the custom image to the following directory:Local Drive:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\PublishingLayouts\en-us
c. Update the Description. Enter a description for your master page:
d. Update the image names:
8. Save the ProvisionedFiles.xml file.
9. Create a preview image in the language folder (in this case, en-us).















10. Next, open the Feature.xml file in Notepad or a similar editing application. Local Drive:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\YourFeature
11. There are four things you need to edit in this file:
e. Change the Feature ID to a unique GUID. You can generate GUIDs in Visual Studio (Tools - Create GUID - Registry Format - Copy). Paste the new GUID for the ID and remove the curly brackets.
f. Update the title:Title="Custom Master Pages"
g. Update the description:Description="Custom master pages for use across multiple site collections."
h. Change the Hidden state to False:Hidden="False"
12. Save the Feature.xml file.
13.Recycle the Application Pool for the site you plan to install the Feature on, or reset IIS (Command Prompt - IISRESET).
14. You are now ready to install the new Feature on the web server. Open a Command Prompt and enter the following:
i. Change directories to the BIN folder in the 12 hive so you can use STSADM.exe:cd C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN
j. Launch STSADM and install the feature:stsadm -o installfeature -name YourFeatureDirectoryName
15. Now we will activate the feature on the site.
k. Open your site and navigate to the Site Collection Features settings page. Site Actions - Site Settings - Modify All Site Settings - Site Collection Features (under the Site Collection Administration submenu).
l. The new feature will be listed:










m. Select Activate.

16. The master pages are now ready to use on the site. Navigate to the Master Page settings by selecting Site Settings in the breadcrumbs and choosing Master Page. (Or Site Actions - Site Settings - Modify All Site Settings - Master page (under the Look and Feel submenu).
17. Depending on your requirements, in either or both the Site Master Page setting and the System Master Page setting, select your drop down box and choose your custom master page.













18. Select OK.
Adding to our Feature: Adding More Custom Master Pages to your Feature
If you ever need to add new master pages to this feature, you can edit the Feature and redeploy it. Alternately, you can create a new Feature for each custom master page. For that scenario, just follow the steps above for creating a new feature. The following outlines how to update your Feature with new master pages.
  1. Navigate to your custom master page Feature directory and add the appropriate files for your new master pages.
  2. Navigate to and open the ProvisionedFiles.xml file. Add a FILE tag block for each new master page for both the OSGMasterPages Module and the PublishingLayoutPreviewImages Module. Save the file.
  3. Recycle the Application Pool for the site you plan to install the Feature on, or reset IIS (Command Prompt - IISRESET).
  4. You are now ready to reinstall the updated Feature on the web server. Open a Command Prompt and enter the following:
    a. Change directories to the BIN folder in the 12 hive so you can use STSADM.exe:cd C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN

b. Launch STSADM and install the feature:

stsadm -o installfeature -name YourFeatureDirectoryName -force

5. Now we will deactivate and reactivate the feature on the site.

a. Open your site and navigate to the Site Collection Features settings page. Site Actions - Site Settings - Modify All Site Settings - Site Collection Features (under the Site Collection Administration submenu).

b. Your existing feature will be listed:




c. Select Deactivate.
d. A warning message will appear. Select Deactivate the feature.
e. The Feature list will reload. Select Activate next to your custom feature.

6. Your new master pages are ready for use.

Custom Site Theme for SharePoint 2007

1. On the SharePoint Server go to the Themes folder e.g. C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\THEMES

2. Copy one of the theme folders from there and paste it in the same directory and give the folder a unique name, say MyTheme.









3. Find the .inf file in the copied folder, and rename it with the name given to the folder i.e. in this example rename that .inf file with MyTheme.INF
4. Open the .inf file and assign the same name i.e. MyTheme to the title in the [info] section of the file, and in the [titles] section replace the previous names with your new name.









5. There is one theme.css file in that MyTheme folder, open that, delete all the classes from that file and place your own css classes in that file.
6. Open “C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\1033\SPTHEMES.XML” file with notepad










7. Add the following lines under tag

MyTheme
MyTheme
This is custom theme.
images/MyTheme.gif
images/MyTheme.gif

8. Where Template ID must be that of same name as that of the folder.
9. In order to display thumbnail and preview correctly, you will need to capture the screen and save the file in "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\IMAGES" folder with MyTheme.gif name. You can change the .gif file name if you change the thumbnail and preview file names in tag.
10. Do an iisrest for the server to recognize the new theme.
11. Open your SharePoint site and go to the theme page by typing following URL in address bar: _layouts/themeweb.aspx









12. Select the theme and apply it to your site by clicking the Apply button.
To change your SharePoint theme, please follow these steps:
1. Open a web browser and log into SharePoint









2. Click Site Actions and select Site Settings
3. Under Look and Feel, click Site theme.
4.Choose a theme from the list.












5.Click Apply.
Common error when we applying the theme
A theme with the name "THEMENAME 1011" and version already exists on the server.
1.(THEMENAME is the name of theme you have created).
WHY?? I had followed standard steps and yet I get the error? hum.... something cheesy here. Guess what? the theme name I had selected for my there was longer than 8 characters!!!! That is it!!! I made it 7 characters and it worked fine! So if you have such error, that might be the reason (also AFAIK, you have to make sure CodePage is unique)
OR
2.Go into SharePoint Designer and open the subsite. Under the _theme folder, delete the folder for the theme you just created.
That should resolve the error.