lundi 17 juin 2013

Package and deploy page layout and master page for SharePoint 2013

There is a lot of new parameters available in the new SharePoint 2013 about page layouts and master page packaging and deployment.

Provision a page layout in sharepoint 2013


A couple of things have changed. The new markup that SharePoint itself uses for provisioning a page layout file looks like this:
Note: you can check this by creating a design package via the new Design Manager, and check the content that has been generated.

Provision a published version 

How to Provision Your Master Pages

For provision master pages, the same approach as discussed above can be used. The only difference will be the properties you're going to provide. The properties that I use in my elements file the following:

vendredi 14 juin 2013

SharePoint Get Convivial URL for a specific Term by Label

You can use the following function in order to retrieve the convivial url associated for a specific term if you use the navigation thanks to the termstore in sharepoint 2010 and 2013


        /// Get convivial URL for a specific term using Label
        /// </summary>
        /// <param name="navigation_Group_Name">Navigation group name for the site collection</param>
        /// <param name="navigation_TermSet_Name">Termset name used for termstore navigation</param>
        /// <param name="navigation_Nom_Term">Name of the term you want to retrieve</param>
        /// <param name="navigation_default_url">Default url used if none term match the label filter</param>
        /// <param name="site"></param>
        /// <returns>site relative convival url   /</returns>
        public static string GetUrlConvivialForTerm(
            string navigation_Group_Name,
            string navigation_TermSet_Name, 
            string navigation_Nom_Term, 
            string navigation_default_url,
            SPSite site)
        {
            string url = string.Empty;
            //Utiliser SPContext SPContext.Current.Site
            TaxonomySession session = new TaxonomySession(site, false);
            TermStore store = session.TermStores[0];
            CacheManager cm = new CacheManager();
            TermSet tHE = TermManager.GetTermSet(navigation_Group_Name, navigation_TermSet_Name, site.RootWeb.Url);

            NavigationTermSet navTermSet = NavigationTermSet.GetAsResolvedByWeb(tHE, site.RootWeb,
                           StandardNavigationProviderNames.GlobalNavigationTaxonomyProvider);

            IEnumerable<NavigationTerm> terms = navTermSet.Terms.Where(t => t.GetTaxonomyTerm().Name.Equals(navigation_Nom_Term));
           
            if(terms != null)
            {
                NavigationTerm term = terms.FirstOrDefault();
                if (term != null)
                {
                    url = term.GetWebRelativeFriendlyUrl();
                }
            }

            if(url.Equals(string.Empty))
            {
                return navigation_default_url;
            }
            else
            {
                return url;
            }
        }