Here is the scenario: you`re working on a SharePoint intranet based of SharePoint team site template; your client asks you to add extra links to SharePoint quick launch navigation menu that will point users to external locations and some views on libraries within your portal. You need to add those links as part of your solution package. How do you do that?
One of the ways you can achieve that is by using a feature with an event receiver and execute adding code that will take care of adding those links to already created site either as a part of the deployment or once the site has been deployed.
Here is how my feature.xml will look like:
<?xml version=”1.0″ encoding=”utf-8″?>
<Feature xmlns=”http://schemas.microsoft.com/sharepoint/”
Id=”E8931816-9652-4f17-86F1-2A8772418C96″
Title=”Add Quick Launch Links”
Description=”Add Quick Launch Links”
Version=”1.0.0.0″
Scope=”Web”
Hidden=”False”
ImageUrl=”"
ReceiverAssembly=”Ahs.Cts.SharePoint, Version=1.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxxx”
ReceiverClass=”MyAccount.AddQuickLaunchLinks”>
<ElementManifests>
</ElementManifests>
</Feature>
class AddQuickLaunchLinks : SPFeatureReceiver{#region Eventspublic override void FeatureActivated(SPFeatureReceiverProperties properties){using (SPWeb rootweb = properties.Feature.Parent as SPWeb){SPNavigationNodeCollection nodes = rootweb.Navigation.QuickLaunch;SPNavigationNode navNode = new SPNavigationNode(“My List”, “~/Page1.aspx”, true);nodes.AddAsFirst(navNode);}}……………………………