Loading...

Thursday, September 13, 2012

Role Based Navigation:Role Based QuickLaunch

Its the common requirement  everywhere to create the RoleBased QuickLaunch and Global Navigation
Following code snippet hides the Firstnode of Quick Launch for Users other than owners and admins,
To implement this
Edit the Master Page in SPD and add this css along with SPsecurity Trimmed Control in head section of master page(Only in following sequence)

1)Following css will be available for all users

<style type="text/css">
/* mainlinks */
.menu-vertical > ul.root > li.static:first-child > .menu-item{

display:none;
}
/* Sublinks */
.menu-vertical > ul.root > li.static:first-child   > ul.static  {

display:none;
}

</style>
2)Following css will be only  available for Owners/admins

<SharePoint:SPSecurityTrimmedControl ID="sitePerms" PermissionsString="ManageWeb" runat="server">
 <style type="text/css">
 /* mainlinks */
.menu-vertical > ul.root > li.static:first-child > .menu-item{

display:block;
}
/* Sublinks */
.menu-vertical > ul.root > li.static:first-child   > ul.static  {

display:block;
}

 </style>
</SharePoint:SPSecurityTrimmedControl>


For extensive branding of QuickLaunch following links are very useful

To Deploy , create the feature to replace the existing master page


Sunday, September 9, 2012

How To Create Solution Package To Deploy Lists With Lookup Columns

To save the time and work pressure,Some of the developers end up deploying lists by 'Save As Template' method.
My request to all those developers is not to go by that way(specially for new learners). Just take the advantage of ,What feature MS Visual Studio 2010 for SharePoint provides.
 Because there are several disadvantage of this ('Save as Template') method. and When it comes for the lists with Parent-Child relationship which includes lookup column it's terrible.
Not only for this post,think of deployment perspective while finalizing any approach for development.
To Develop solution package for Lists With Lookup Columns
A)Create Content Type and Site Columns for Parent List 
1)Navigate to any source SharePoint site.
Site action -->Site Settings-->Site Columns Create site column 'Parent Column' with Single line of Text

Now add this site column to Parent Content Type,
to do so,create new Content Type which inherits from List Content Type and add parent column

2)Create Custom List ParentList  and Enable management of Content Type of this List(List Settings 
-->Allow management Of Content Type
Add from existing  Site Content Type and Select Parent Lookup Content Type
and delete the existing Item Content Type

B)Create Content Type and Site Columns for Child List
 Site action -->Site Settings-->Site Columns Create site column 'Foreign Column' with Lookup Type as described in below image
  
  Now add this site column to Child Content Type  and Associate this content type with Child List in the similar way , as that of Parent List(As described above in Section A )

C)Get the wsp file of the site and Import to Visual Studio
1)Browse to _Layouts/savetmpl.aspx with include contents check box checked and save it to the local disk(this link is not visible for publishing sites in site settings)
2)Visual Studio 2010-->run as admin-->New Project-->SharePoint-->Import Solution Package.
Select deploy as Farm solution and select the wsp saved in above in Step  C 1.
Press Shift on Keyboard,select first and last row and uncheck all the files shown in grid
Now you have to be very careful.Make sure that following items are selected before clicking on next
1)Parent Column, Foreign Column(Child Column) site columns
2)Parent Content Type and  Child Content Types
3)Parent List Instance and  Child List Instance
4)ListParentList_Pages and ListChildList_Pages

On clicking Finish ,If you get Popup for  dependencies,Click on 'No'  and Solution should appear like below

Please add to the comments If you get any deployment errors.while doing this activity. I renamed the Child List before Importing.so I got the deployment errors for List not found .Then I ran replace all for new list name and Its working now :)

If during deployment few more columns and Content type needs to be deployed , get  the schema  through powershell add to this solution.

Download Source