Copied to clipboard

Flag this post as spam?

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


  • Anthony Dang 1404 posts 2558 karma points MVP 3x c-trib
    Aug 20, 2013 @ 15:58
    Anthony Dang
    0

    Template import empty in MVC mode - Umbraco 6.1.3

    Template imports as empty when "-" is in the alias

    uSync will output the following:

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <Template>
      <Name>Somthing-Else</Name>
      <Alias>Somthing-Else</Alias>
      <Design><![CDATA[@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @{
        Layout = null;
    }]]></Design>
    </Template>

     

    But when importing this same file, the template is empty

  • Kevin Jump 2309 posts 14673 karma points MVP 7x c-trib
    Aug 20, 2013 @ 16:22
    Kevin Jump
    0

    OK, - uSync just calls Template.Import() from the core, - I'll have a look see.

  • Kevin Jump 2309 posts 14673 karma points MVP 7x c-trib
    Aug 20, 2013 @ 16:38
    Kevin Jump
    0

    I can't reproduce this,

    Fresh install Umbraco v6.1.3 - (Mvc switched on) uSync v1.4.0

    create a template with a - in it's name add some content. save

    my def.config file

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <Template>
      <Name>test-template</Name>
      <Alias>test-template</Alias>
      <Design><![CDATA[@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @{
        Layout = null;
    }
    
    <h1>hello</h1>]]></Design>
    </Template>
    

    copy the file, delete the template from umbraco

    put the file back, restart the app

    template is imported as expected

    anything special about the template you had ?

  • Anthony Dang 1404 posts 2558 karma points MVP 3x c-trib
    Aug 20, 2013 @ 18:16
    Anthony Dang
    0

    After some investigations it turns out to be an umbraco bug.

    The bug occurs because of the name not being the same as the alias. The result is that umbraco creates a node without the @ symbol, indicating that it's created a masterpage, not a view. However no file is created at all. See bellow.

     

      

    Looking into the source, we found https://github.com/umbraco/Umbraco-CMS/blob/e41d3c7e844b63780a4842ccd105e8bb593e4d54/src/umbraco.cms/businesslogic/template/Template.cs

     

    You pass the xml to Import() which is line 770. This calls MakeNew.

    On line 399 MakeNew() executes and uses the name to try to get the template by alias.

    This is where it starts going wrong.

     

     

     

Please Sign in or register to post replies

Write your reply to:

Draft