Sunday, 22 January 2012

BBIINNCC reference

Deploying page layouts URL:
 <Module Name="masterpage" Url="_catalogs/masterPage">
<File Path="masterpage\BincArticleLeft.aspx" Url="BincArticleLeft.aspx"  Type="GhostableInLibrary">
     
      <Property Name="Title"
            Value="abc" />
      <Property Name="MasterPageDescription"
                Value="The article page with image on left contains an image field and a rich text field." />
      <Property Name="ContentType"
                Value="$Resources:cmscore,contenttype_pagelayout_name" />
      <Property Name="PublishingPreviewImage" Value="/_catalogs/masterpage/en-US/Preview Images/ArticleLeft.png"/>
      <Property Name="PublishingAssociatedContentType"
      Value=";#ArticleBInc;#0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF39002b979b5c686349eb92d939ff73924bec009f244e5227374f12aee85340cb147169;#"/>
    </File>
</Module>

Deploying page Pages:
<Module Name="Pages" Path="Pages" Url="$Resources:cmscore,List_Pages_UrlName;">

<File Name="Accueil.aspx" Url="Home.aspx"  Path="\Home.aspx" Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE">
      <Property Name="Title" Value="Accueil"/>
      <Property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/ArticleLinks.aspx, Title"/>
      <Property Name="ContentType" Value="Page Article Binc" />
      <Property Name="ContentTypeId"
                Value="0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF39002b979b5c686349eb92d939ff73924bec009f244e5227374f12aee85340cb147169" />
      <Property Name="PublishingPageContent"
        Value="page content comes here" />
    </File>
</Module>

List Instance:
 <List FeatureId="4bcccd62-dcaf-46dc-a7d4-e38277ef33f4" Type="851"
                    Title="Images et Photos" Url="$Resources:core,lists_Folder;/ImagesPhotos"
                      Description="Liste des images et photos publique du département" QuickLaunchUrl="$Resources:core,lists_Folder;/ImagesPhotos" />
 <List FeatureId="00BFEA71-EC85-4903-972D-EBE475780106" Title="Événements"
              Type="106"  Description="Liste des événements publiques du département"
              Url="$Resources:core,lists_Folder;/$Resources:core,calendar_Folder;"
              QuickLaunchUrl="$Resources:core,lists_Folder;/$Resources:core,calendar_Folder;/Calendar.aspx" />
 <List Title="Annonces Privées" VersioningEnabled="True" EnableMinorVersions="True"
         FeatureId="00bfea71-d1ce-42de-9c63-a44004ce0104"
         Url="AnnoncesPrivees"
         Description="Liste des annonces du département" Type="104">
        </List>

  <List Title="Tâches" VersioningEnabled="True" EnableMinorVersions="True"
       FeatureId="00bfea71-a83e-497e-9ba0-7a5c597d0107"
       Url="Taches"
       Description="Liste des tâches du département" Type="107">
        </List>


Creating Views in onet.xml:
 <Module Name="DefaultBlank" Url="" Path="">
      <File Url="default.aspx">
 <View  BaseViewID="0" List="AnnoncesPrivees" WebPartZoneID="webpartzone1"  DisplayName="Annonce du département" RowLimit="1"  >
          <![CDATA[
              <webParts>
                  <webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
                      <metaData>
                          <type name="Microsoft.SharePoint.WebPartPages.XsltListViewWebPart,Microsoft.SharePoint,Version=14.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c" />
                          <importErrorMessage>Cannot import this Web Part</importErrorMessage>
                      </metaData>
                      <data>
                          <properties>
                              <property name="Title">Annonce du département</property>
                              <property name="AllowConnect" type="bool">True</property>
                              <property name="AllowClose" type="bool">False</property>
                          </properties>
                      </data>
                  </webPart>
              </webParts>
          ]]>
        </View>
</File>
</Module>

Image webpart:
<AllUsersWebPart WebPartZoneID="webpartzone10" WebPartOrder="4">
          <![CDATA[
      <WebPart xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.microsoft.com/WebPart/v2">
        <Title>Image Web Part</Title>
        <FrameType>None</FrameType>
        <Description>Use to display pictures and photos.</Description>
        <PartImageSmall />
        <PartImageLarge>/_layouts/images/msimagel.gif</PartImageLarge>
        <Assembly>Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
        <TypeName>Microsoft.SharePoint.WebPartPages.ImageWebPart</TypeName>
        <ImageLink xmlns="http://schemas.microsoft.com/WebPart/v2/Image%22%3E/_layouts/images/homepageSamplePhoto.jpg%3C/ImageLink>
        <AlternativeText xmlns="http://schemas.microsoft.com/WebPart/v2/Image" />
        <VerticalAlignment xmlns="http://schemas.microsoft.com/WebPart/v2/Image%22%3EMiddle%3C/VerticalAlignment>
        <HorizontalAlignment xmlns="http://schemas.microsoft.com/WebPart/v2/Image%22%3ECenter%3C/HorizontalAlignment>
        <BackgroundColor xmlns="http://schemas.microsoft.com/WebPart/v2/Image%22%3Etransparent%3C/BackgroundColor>
      </WebPart>
   ]]>
        </AllUsersWebPart>

Adding Content types to list and setting default content type:
using System.Collections.Generic;

 SPContentType contype = web.ContentTypes["Page Article Binc"];
// to get the content type from root site
//SPContentType contype1 = SPContext.Current.Site.RootWeb.ContentTypes["Page Article Binc"];
 SPList listpages12 = web.Lists["Pages"];
                    listpages12.ContentTypes.Add(contype);
                    listpages12.Update();
                    SPContentTypeCollection currentOrder = listpages12.ContentTypes;
                    List<SPContentType> result = new List<SPContentType>();
                    foreach (SPContentType ct in currentOrder)
                    {
                        if (ct.Name.Contains("Page Article Binc"))
                        {
                            result.Add(ct);
                        }
                    }
                    listpages12.RootFolder.UniqueContentTypeOrder = result;
                    listpages12.RootFolder.Update();
                    listpages12.Update();


Setting default page:
  PublishingWeb publishingWeb = PublishingWeb.GetPublishingWeb(web);
                PublishingPageCollection webpages = publishingWeb.GetPublishingPages();
                                web.AllowUnsafeUpdates = true;

                SPFile welcomeFile = web.GetFile(web.ServerRelativeUrl + "pages/home.aspx");
             
                publishingWeb.DefaultPage = welcomeFile;
                publishingWeb.Update();
   web.AllowUnsafeUpdates = true;

Hiding Page Layouts:
PublishingWeb publishingWeb = PublishingWeb.GetPublishingWeb(web);
 PageLayout[] layouts = publishingWeb.GetAvailablePageLayouts();
 foreach (PageLayout layout in layouts)
                {                  
                   
                    if (layout.Name.Equals("ArticleLeft.aspx"))
                    {
                        SPListItem item1 = layout.ListItem;
                        item1.File.CheckOut();
                        item1["PublishingHidden"] = true;
                        item1.Update();
                        item1.File.CheckIn("CheckIn");
                        item1.File.Approve("s");

                    }
}


Custom Left Navigation:
 private void displayleftnav(SPSite site, string url)
        {
            using (SPSite siteCollection = new SPSite(site.Url))
            {
               
                using (SPWeb web1 = siteCollection.OpenWeb(url))
                {
                    PublishingWeb publishingWebs = PublishingWeb.GetPublishingWeb(web1);
                                     
                    publishingWebs.Navigation.InheritGlobal = true;
                    publishingWebs.Navigation.GlobalIncludePages = false;
                    publishingWebs.Navigation.GlobalIncludeSubSites = false;
                    publishingWebs.Navigation.ShowSiblings = false;
                   // publishingWebs.Navigation.CurrentIncludeSubSites = true;
                   // publishingWebs.Navigation.CurrentIncludePages = false;
                    if (web1.Url.Contains("Prive"))
                    {
                        publishingWebs.Navigation.InheritGlobal = true;
                        publishingWebs.Navigation.GlobalIncludePages = false;
                        publishingWebs.Navigation.GlobalIncludeSubSites = false;
                        publishingWebs.Navigation.ShowSiblings = false;
                        publishingWebs.Navigation.CurrentIncludeSubSites = false;
                        publishingWebs.Navigation.CurrentIncludePages = false;
                        publishingWebs.Update();
                         SPNavigationNodeCollection CurrentNavigationNodes = web1.Navigation.QuickLaunch;
                        SPNavigationNode bib = new SPNavigationNode("documents","#",true);
                          SPNavigationNode FirstFolder1 = CurrentNavigationNodes.AddAsFirst(bib);
                          SPNavigationNode childNav1 = new SPNavigationNode("Documents1", web1.ServerRelativeUrl.ToString() + "/Documents1", true);
                          FirstFolder1.Children.AddAsFirst(childNav1);
                          childNav1 = new SPNavigationNode("Documents2", web1.ServerRelativeUrl.ToString() + "/Documents2", true);
                          FirstFolder1.Children.AddAsLast(childNav1);
                          childNav1 = new SPNavigationNode("Documents3", web1.ServerRelativeUrl.ToString() + "/Documents3", true);
                          FirstFolder1.Children.AddAsLast(childNav1);
                          childNav1 = new SPNavigationNode("Vidéos", web1.ServerRelativeUrl.ToString() + "/Lists/Videos", true);
                          FirstFolder1.Children.AddAsLast(childNav1);
                          //Then second folder
                          SPNavigationNode SecondFolder1 = CurrentNavigationNodes.AddAsLast(new SPNavigationNode("Outils", "#", true));
                          SPNavigationNode childNavSecond1 = new SPNavigationNode("Liens utiles", web1.ServerRelativeUrl.ToString() + "/LiensUtiles", true);
                          SecondFolder1.Children.AddAsFirst(childNavSecond1);
                          childNavSecond1 = new SPNavigationNode("Mes liens", web1.ServerRelativeUrl.ToString() + "/MesLiens", true);
                          SecondFolder1.Children.AddAsLast(childNavSecond1);
                          //Third Folder
                          SPNavigationNode ThirdFolder1 = CurrentNavigationNodes.AddAsLast(new SPNavigationNode("Autres", "#", true));
                          //add children
                          SPNavigationNode childNavThird1 = new SPNavigationNode("Annonces", web1.ServerRelativeUrl.ToString() + "/AnnoncesPrivees", true);
                          ThirdFolder1.Children.AddAsFirst(childNavThird1);
                          childNavThird1 = new SPNavigationNode("Articles", web1.ServerRelativeUrl.ToString() + "/Pages", true);
                          ThirdFolder1.Children.AddAsLast(childNavThird1);
                    }
                    // Maximum number of dynamic items to show within this level of navigation:
                    //publishingWeb.Navigation.GlobalDynamicChildLimit = 60;
                    //Update the changes
                    publishingWebs.Update();
                }
            }

        }


Adding Custom Top Navigation
 private void AddGlobalNavigation(SPSite site)
        {
           
            SPWeb web = site.OpenWeb();
            SPNavigationNodeCollection topNavigationNodes = web.Navigation.TopNavigationBar;
            SPNavigationNode objItem = new SPNavigationNode("Siège Social", "/Pages/Fr/SiegeSocial.aspx", true);
            //This should be for first folder
            SPNavigationNode FirstFolder = topNavigationNodes.AddAsFirst(objItem);
            //Then add its children
            SPNavigationNode childNav = new SPNavigationNode("Notre équipe", "/Pages/Fr/NotreEquipe.aspx", true);
            FirstFolder.Children.AddAsFirst(childNav);
            childNav = new SPNavigationNode("Organigrammes", "/Pages/Fr/Organigramme.aspx", true);
            FirstFolder.Children.AddAsLast(childNav);
            childNav = new SPNavigationNode("Plan de continuité des affaires", "/Fin/Pages/Fr/PlanContinuiteAffaires.aspx", true);
            FirstFolder.Children.AddAsLast(childNav);
            childNav = new SPNavigationNode("Mesures d'urgence", "/Fin/Pages/Fr/MesuresUrgence.aspx", true);
            FirstFolder.Children.AddAsLast(childNav);
            childNav = new SPNavigationNode("Plan des étages", "/Fin/Pages/Fr/PlanEtages.aspx", true);
            FirstFolder.Children.AddAsLast(childNav);


            //Then second folder
            SPNavigationNode SecondFolder = topNavigationNodes.AddAsLast(new SPNavigationNode("Actualité", "#", true));
            //add children
            SPNavigationNode childNavSecond = new SPNavigationNode("Revues de presse", "/Pages/Fr/RevueDePresse.aspx", true);
            SecondFolder.Children.AddAsFirst(childNavSecond);
            childNavSecond = new SPNavigationNode("Notes internes", "/Pages/Fr/NotesInternes.aspx", true);
            SecondFolder.Children.AddAsLast(childNavSecond);
            childNavSecond = new SPNavigationNode("Activités et événements", "/Pages/Fr/ActivitesEtEvenements.aspx", true);
            SecondFolder.Children.AddAsLast(childNavSecond);
            childNavSecond = new SPNavigationNode("Avis de nomination", "/Pages/Fr/AvisNomination.aspx", true);
            SecondFolder.Children.AddAsLast(childNavSecond);
            childNavSecond = new SPNavigationNode("Autres nouvelles", "/Pages/Fr/AutresNouvelles.aspx", true);
            SecondFolder.Children.AddAsLast(childNavSecond);
            childNavSecond = new SPNavigationNode("Résultats trimestriels", "/AP/RI/Pages/Fr/ResultatsTrimestriels.aspx", true);
            SecondFolder.Children.AddAsLast(childNavSecond);
            childNavSecond = new SPNavigationNode("Actualité par fonction", "/Pages/Fr/ActualiteFonction.aspx", true);
            SecondFolder.Children.AddAsLast(childNavSecond);
}
}
}

No comments:

Post a Comment