Get SharePoint 2010 Publishing Site Page Layout Programmatically

12. January 2012 03:54 by Rashid Aziz in Sharepoint blogs  //  Tags: , ,   //   Comments
I have come across a business requirement, while implementing this I need to get publishing site page layout on sharepoint 2010 using server object model. After a little research I managed to do this, I think it is worth to share code with you guys. The code below was used to get the default page layout of a publishing web site in SharePoint 2010. private static void GetPageLayout() { using (SPSite site = new SPSite("Publishing Site Collection URL")) { using (SPWeb web = site.OpenWeb()) { PublishingWeb publishingWeb = PublishingWeb.GetPublishingWeb(web); PageLayout pageLayout = publishingWeb.DefaultPageLayout; Console.WriteLine("Layout Name: "+pageLayout.Name + " Site URL: " + pageLayout.ServerRelativeUrl); } } }  

SharePoint blog with attachment capability workaround

24. November 2011 07:29 by Rashid Aziz in Sharepoint blogs  //  Tags: , ,   //   Comments
By default there are not any settings in sharepoint to enable attachments with blog posts. It is not a perfect way to do this, but worth to mention on my blog I think. I have done a workaround to achieve this Create a custom list inherited form Item with default columns. Create new item “give it a title” and attach your document with it. Now in your post list create a lookup column with the title “Attachment” which will look up to the “Title” column of your custom list. Edit the view of you posts web part on the blog main page and enable it to display the lookup field. You can now see the attachment in the footer. I hope this blogs helps J

SharePoint Cloud Based Service Providers

I have listed few cloud based service providers for SharePoint. If you guys came across any other cloud based service please add it in comments. I am just trying to put all cloud service provider in one place. Microsoft Office 365 Microsoft is committed to delivering business-grade cloud services that work together to support new levels of innovation, efficiency, and agility for your organization http://www.microsoft.com/en-gb/office365/online-software.aspx American Data Technology You as a client benefit from our proven track record of 15 years expertise as a web hosting services provider. http://www.localweb.com/ Igroup Hosted SharePoint They love SharePoint and they use the platform widely within their business. They aim to stand out in our market by offering our products and services in the most self-supporting and responsible way they can. http://www.sharepoint-cloudhosting.com/ Goiwx Goiwx is a cloud hosting services provider specialized in ERP, CRM and other front and back office solutions that you own or want to use. http://www.goiwx.com/ Quantix innovative IT Services Quantix is one of the UK's premier providers of, Managed Cloud Services and Infrastructure Solutions for Enterprises and Independent Software Vendors. http://www.quantix-uk.com/ 724 Internet Solutions 724 is one of the oldest Cloud Computing Providers. In business since 1996, and Hosting SharePoint since 1999, http://www.724hosting.com/ Rackspace Hosting Rackspace Cloud offers four hosting products: Cloud server for on-demand computing power; Cloud sites for robust web hosting http://www.rackspace.com Pay Per Cloud PayPerCloud is a full service cloud hosting company. Their solutions are delivered and backed up with EXPERT level technical support unmatched in the industry http://www.paypercloud.com/ WEB HOSTING UK The number 1 company in the UK offering reliable and affordable web hosting solutions http://www.webhosting.uk.com/ Red Ember Solutions They are dynamic Perth Company specialising in custom solutions tailored to your businesses exacting requirements. http://www.redember.com.au/

Creating users alerts using PowerShell in SharePoint 2010

23. November 2011 07:38 by Rashid Aziz in Sharepoint blogs  //  Tags: ,   //   Comments
We had a requirement in SharePoint 2010 to automate the creation of alerts based on SPS group membership. After spending some time searching for solution I have managed to write this code in PowerShell to automate the process. I think it worth sharing with you guys. Creating users alerts using PowerShell code: $web = Get-SPWeb "http://eblogin.com" $group = $web.Groups["eblogin members"] $list = $web.Lists["eblogin documents"] foreach ($user in $group.Users){      $alert = $user.Alerts.Add()      $alert.Title = "eblogin alerts"      $alert.AlertType = [Microsoft.SharePoint.SPAlertType]::List      $alert.List = $list      $alert.DeliveryChannels = [Microsoft.SharePoint.SPAlertDeliveryChannels]::Email      $alert.EventType = [Microsoft.SharePoint.SPEventType]::Add      $alert.AlertFrequency = [Microsoft.SharePoint.SPAlertFrequency]::Immediate      $alert.Update() } $web.Dispose() You can also change the DeliveryChannels option to SMS  and AlertFrequenct option to Daily. You could run different scripts for your different SharePoint groups.

Moving Items Between SharePoint Lists

I came across a scenario where I want to copy large amount of content from one sharepoint list to another.  I have done this by creating custom view on lists and copied contents using datasheet view. Please follow these steps to achieve this. Create one list view for both lists which should contain all the columns that you want to copy, also make sure that columns are not read only and they are not system generated columns like “Created by, Created”. Open both lists in different browsers Select newly created view for both list Open this view in datasheet view on both lists Select all the items in the source list and click copy Select the first cell of the available row in the destination list and click paste All your items should be copied successfully, now you can open the list in standard view and see that all data is copied. This works as long as you don't need to copy any of the system generated content like (created by filed). You need to use list view web parts or write custom code to achieve that.

Custom master page deployment in SharePoint 2010

20. May 2011 02:52 by Rashid Aziz in Sharepoint blogs  //  Tags: ,   //   Comments
Today I am going to show you that how easily you can deploy your custom master page as a SharePoint feature and it automatically change the site default master page when you activate this feature. For this you need to create new empty SharePoint project. Add a new item to the project and select module and call is “Module1”. Once the module is created it contains “element.xml” and “sample.txt” file, rename the “sample.txt” file to “customMaster.master” as shown in below image.               Now you can copy code from your custom master page which you want to deploy(If you don’t have your custom code then you can use SharePoint 2010 designer and copy the contents of v4.master and past them in your customMaster.master file in Visual Studio. Make the changes you want to. Copy the following code and replace your “element.xml” file. <?xmlversion="1.0" encoding="utf-8"?> <Elementsxmlns="http://schemas.microsoft.com/sharepoint/">   <ModuleName="Module1" Url="_catalogs/masterpage">     <FilePath="Module1\customMaster.master" Url="customMaster.master" />   </Module> </Elements> Now you have to add feature event receiver, so on feature activation this custom master page will be your default master page. To do this, right click on your feature1 and select “Add event receiver” Replace the “FeatureActivated” and “featureDeactivating” method with the followings public override void FeatureActivated(SPFeatureReceiverProperties properties)         {             SPSite site = (SPSite)properties.Feature.Parent;             SPWeb web = site.RootWeb;             Uri masterUri = new Uri(web.Url + "/_catalogs/masterpage/custommaster.master");             web.MasterUrl = masterUri.AbsolutePath;             web.CustomMasterUrl = masterUri.AbsolutePath;             web.Update();         }  public override void FeatureDeactivating(SPFeatureReceiverProperties properties)         {             SPSite site = (SPSite)properties.Feature.Parent;             SPWeb web = site.RootWeb;             Uri masterUri = new Uri(web.Url + "/_catalogs/masterpage/v4.master");             web.MasterUrl = masterUri.AbsolutePath;             web.CustomMasterUrl = masterUri.AbsolutePath;             web.Update();         } Now deploy the feature, when you will activate the feature it will replace you default master page with “customMaster.master” , and when you deactivatethe feature it will replace  to default master page which is V4.master.

SharePoint feature stapling with site definition

I have created a site definition, there are many ways to use features with this site definition, You can create a site from this site definition and deploy feature on that newly created site, you can also include features in onet.xml of site definition file and then create site from it. Another way to do is by feature stapling which associate your feature to the site definition. In this blog I will demonstrate how you can use feature stapling to associate your features with site definition. To use the  stapling, you need features which you like to map with the site definition. You need to create a second feature which does the stapling.  The solution sample is given below The manifest.xml file if you are wrapping your feature in a solution.  <?xmlversion="1.0"encoding="utf-8"?>  <Solutionxmlns="http://schemas.microsoft.com/sharepoint/"SolutionId="0579AAC2-9E7E-478E-AFE9-D5EC426055E4">   <FeatureManifests>     <FeatureManifestLocation="EB.MyDemo.FeatureStapling\feature.xml" />   </FeatureManifests> </Solution> Note: The feature stapling will not affect any sites which have been already created from a site definition, only subsequent site will take the affect. But you can activate features individually on the site.

Master page fly out quick launch menu in SharePoint

15. March 2011 08:40 by Rashid Aziz in Sharepoint blogs  //  Tags: ,   //   Comments
It is very simple to modify the appearance of “Quick launch” by setting attributes of master page. You can change attributes to collapse the menu view to heading and the fly out menu will be used to show subordinate menu items. The menu control is defined in the default master for the website. Here are the steps you need to perform to get the fly out quick launch menu. 1.   Open the browser and go to the site which “Quick launch” menu you want to customise. 2.   Navigate to Site actions > Site Setting > Master pages. 3.   Select the V4.masetr master page; click “Edit Document” form the ribbon. 4.   Go to <SharePoint:AspMenu id=”V4QuickLaunchMenu”  section of your page code and replace the “StaticDisplayLevels” attribute value to 1 and “MaximumDynamicDisplayLevels” attribute value to 1 as well.   <SharePoint:AspMenu id="V4QuickLaunchMenu" runat="server" EnableViewState="false" DataSourceId="QuickLaunchSiteMap" UseSimpleRendering="true" UseSeparateCss="false" Orientation="Vertical" StaticDisplayLevels="2" MaximumDynamicDisplayLevels="0" SkipLinkText="" CssClass="s4-ql" />   You can see the before and after effects in the following pictures.                                    Before                                                                                    After

Stay connected

SharePoint Links

Month List