+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Templates and Pages wont publish

Templates and Pages wont publish

4 posts, 0 answered
  1. rolls rolls
    rolls rolls avatar
    24 posts
    Registered:
    02 Nov 2002
    22 Oct 2009
    Link to this post

    Hi
    When i edit either templates or pages ,when i try and save and publish the page just hangs and nothing is getting published.This started all of a sudden.The only bit of code i have added is a globalService which adds cultures.
    Thanks Rolls

      void CmsManager_Executed(object sender, Telerik.ExecutedEventArgs e)  
        {  
            if (e.CommandName == "Publish")  
            {  
                ICmsPage cmsPage = e.Data as ICmsPage;  
                if (cmsPage != null && LocalizationManager.IsDefaultCulture)  
                {  
                    // saves the original current culture    
                    CultureInfo currentCulture = Thread.CurrentThread.CurrentUICulture;  
     
                    CmsManager manager = new CmsManager();  
     
                    int sourceLangID = (cmsPage.LangID == CultureInfo.InvariantCulture.LCID) ? LocalizationManager.DefaultCulture.LCID : cmsPage.LangID;  
                    foreach (CultureInfo culture in LocalizationManager.Cultures.Values)  
                    {  
                        if (culture.LCID == sourceLangID)  
                            continue;  
     
                        if (!cmsPage.LanguageVersions.ContainsKey(culture.LCID))  
                        {  
                            // changes the culture of the current thread    
                            Thread.CurrentThread.CurrentUICulture = culture;  
     
                            // Gets the Cms page for the new culture    
                            ICmsPage tempPage = (ICmsPage)manager.GetPage(cmsPage.ID, true);  
     
                            // Checks out the Cms page creating new staged version    
                            IStagedPage staged = tempPage.Staged.CheckOut();  
     
                            // Copies the content from another language version and saves in into database.    
                            staged.CopyFromLanguage(sourceLangID);  
     
                            // Gets the page from the database, and checkin (Publish)    
                            tempPage = (ICmsPage)manager.GetPage(cmsPage.ID, true);  
                            tempPage.Staged.CheckIn();  
                        }  
                    }  
     
                    // restores the original culture    
                    Thread.CurrentThread.CurrentUICulture = currentCulture;  
                }  
            }  
        }  
     
  2. rolls rolls
    rolls rolls avatar
    24 posts
    Registered:
    02 Nov 2002
    22 Oct 2009
    Link to this post
    I have removed the GlobalService and am still not able to publish.
    Regards Rolls
  3. rolls rolls
    rolls rolls avatar
    24 posts
    Registered:
    02 Nov 2002
    22 Oct 2009
    Link to this post
    Okay I found the problem....I have a button Image as the logo on the Masterpage.If I remove it the template and associated pages publish.
    Thanks Rolls
  4. Luc Baeten
    Luc Baeten avatar
    169 posts
    Registered:
    23 Sep 2005
    27 May 2011
    Link to this post
    Hello Sitefinity team

    I have been using this service code to copy the current page to other cultures as well. This code works perfectly when publishing the page directly an not using the page workflow (so allowPageWorkflow="false"  ) 
    However when I am using the page workflow (so allowPageWorkflow="true" ) then I get the error 'An object with the same primary key already exists in the cache'  but everything seems to work fine: The page is copied to other cultures and can be edited.
    The error doesn't occur in the GlobalService code but occurs after finishing the GlobalService code.

    Have you any idea what the reason could be?

    Kind regards
    Luc
Register for webinar
4 posts, 0 answered