0

I have a site in 2013 with two variations: de-de and en-us.

On feature activation, I try to get list of Available Page Layouts using following code:

 using (SPSite site = new SPSite(siteUrl))
        {
            using (SPWeb web = site.OpenWeb())
            {
                try
                {
                    PublishingWeb curPubWeb = null;
                    if (web.Exists && PublishingWeb.IsPublishingWeb(site.OpenWeb()))
                    {
                         curPubWeb = PublishingWeb.GetPublishingWeb(web);
                        if (curPubWeb != null)
                        {
                           if (lstPageLayoutTemplates != null)
                            {
                                foreach (PageLayout curLayout in curPubWeb.GetAvailablePageLayouts())
                                {
                                    newItem = lstPageLayoutTemplates.Items.Add();
                                    newItem[pageTypeDescriptionColumn] = curLayout.Description;
                                    newItem[pageTypeImageColumn] = curLayout.PreviewImageUrl;
                                    if (!string.IsNullOrEmpty(curLayout.AssociatedContentType.Name))
                                    {
                                        newItem[titleColumn] = "(" + curLayout.AssociatedContentType.Name + ") " + curLayout.Title;
                                    }
                                    else
                                    {
                                        newItem[titleColumn] = curLayout.Title;
                                    }
                                    newItem.Update();
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                { }


            }
        }

If I activate the feature from de-de site, for all the variations, I get entries in Germany. Same way,if I activate feature from en-us, for all the variations, I get entries in English.This is not expected behavior.
I pass url while creating site collection. I get PublishingWeb object correctly. But it returns same page layouts for all variations, no matter what url is passed to create web object.

What am I missing?Any suggestions would be appreciated.

  • So what is the issue?curPubWeb.GetAvailablePageLayouts() us same for both the sites? – Aanchal Jun 16 '14 at 11:18
  • Yep, Actually for german version, it should return german name for page layout but it still returns english version. – Priya Jun 16 '14 at 11:41
  • It may be static name of the pageLayout that is same for the every site. You should check other properties of pageLayout object like curLayout.Name – Aanchal Jun 16 '14 at 13:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.