Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Alex Burr 77 posts 128 karma points
    Mar 09, 2012 @ 17:40
    Alex Burr
    0

    Changing default template in child document types

    I have an odd situation that's more than a little concerning. Nodes built on child document types which have had template changes do not seem to apply the changes until each node is published individually.

    I have three document types:

    - Site Page
      -- Event
      -- News Article

    Each of these document types was allowed templates called "two-column page" and "one-column page". Each of these had the following logic in the template:

    <% if ((umbraco.NodeFactory.Node.GetCurrent().GetProperty("hideSidebar") != null)
                        && (int.Parse(umbraco.NodeFactory.Node.GetCurrent().GetProperty("hideSidebar").Value) != 1)) { %>
                    <umbraco:Item Field="sidebarContent" recursive="true" insertTextBefore="<aside class=&quot;sidebar&quot;>" insertTextAfter="</aside>" runat="server"></umbraco:Item>
                <% } %>

    Some content was created on the site using the "site page" document type, with multiple child nodes of the "event" and "news article" types. 

    Then I needed to create a new template called "basic page", and introduced some logic into the template to check for the existence of the "hideSidebar" property first:

    <% if ((umbraco.NodeFactory.Node.GetCurrent().GetProperty("hideSidebar") != null)
                        && (int.Parse(umbraco.NodeFactory.Node.GetCurrent().GetProperty("hideSidebar").Value) != 1)) { %>
                    <umbraco:Item Field="sidebarContent" recursive="true" insertTextBefore="<aside class=&quot;sidebar&quot;>" insertTextAfter="</aside>" runat="server"></umbraco:Item>
                <% } %>

    I went into each of my document types and updated their default template to "basic page" and removed "one-column page" and "two-column page" from the allowed templates.

    The problem is, pages built on the "Site Page" doc type work fine. But pages built on the "News Article" or "Event" doc types are broken - because they are still using the "two-column page" template despite my removing it as an option.

    I know this because of the error message I see displayed. Note the last line which displays the current template used, it specifies the old template and not the new one.

    Input string was not in a correct format.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

    Exception Details: System.FormatException: Input string was not in a correct format.

    Source Error: 

    Line 12:             <umbraco:Macro Alias="SubNav" homeDocumentType="SiteHomepage" runat="server"></umbraco:Macro>
    Line 13:             <!-- Optional sidebar content -->
    Line 14:             <% if (int.Parse(umbraco.NodeFactory.Node.GetCurrent().GetProperty("hideSidebar").Value) != 1) { %>
    Line 15:                 <umbraco:Item Field="sidebarContent" recursive="true" insertTextBefore="<aside class=&quot;sidebar&quot;>" insertTextAfter="</aside>" runat="server"></umbraco:Item>
    Line 16:             <% } %>

    Source File: d:\webdata\Sites\masterpages\Two-columnPage.master    Line: 14 

    I am able to apply the doc type change by republishing each node one at a time, but publishing the parent and the 'republish entire site' do nothing. Also recycling the app pool (IIS 7) and restarting the website do nothing.

    This is a major problem as this site will potentially have tens of thousands of nodes.

    Someone help please!!!

  • Alex Burr 77 posts 128 karma points
    Mar 09, 2012 @ 17:53
    Alex Burr
    0

    I have some updated information if can be useful to anyone who wishes to help me...

    Here is the content of the cmsTemplate table:

    pk | nodeId | master | alias
    --------------------------------------
    7  | 1088   | 1052   | One-column Page
    8  | 1092   | 1052   | Two-column Page
    13 | 1311   | 1052   | Basic Page

    Here is the content of the cmsContentType table:

    pk | nodeId | alias       | masterContentType
    ----------------------------------------------
    539 | 1071   | SitePage    | 0
    543 | 1146   | Event       | 1071
    544 | 1163   | NewsArticle | 1071

    Here is the content of the cmsDocumentType table:

    contentTypeNodeId | templateNodeId | IsDefault
    ----------------------------------------------
    1071              | 1311           | 1
    1146              | 1311           | 1
    1163              | 1311           | 1
    
    So everything has been saved correctly, and I'm assuming something must be cached that is being applied at load time?
Please Sign in or register to post replies

Write your reply to:

Draft