Copied to clipboard

Flag this post as spam?

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


  • Robert Stocks 6 posts 29 karma points c-trib
    May 17, 2013 @ 17:26
    Robert Stocks
    0

    Template content in uSync overwrites template in filesystem

    If you create a new template (vi umbraco backoffice), and then edit the template outside umbraco.

    Commit both changes to version control, when the next person checks out the code the version of the template in the uSync overides the version in source control.

     

    Prehaps uSync should not store the template content in it's XML file.

  • Kevin Jump 2309 posts 14673 karma points MVP 7x c-trib
    May 17, 2013 @ 19:54
    Kevin Jump
    0

    ahh yes. uSync stored what umbraco exports, it only touches templates at all because their is an ID stored in the DB for doctypes / content to attach to.

    I'll look into changing that behaviour - it will probibly become a configuration option, 

    but beware - in the current version this is also true for stylesheets 

  • Kevin Jump 2309 posts 14673 karma points MVP 7x c-trib
    May 23, 2013 @ 19:18
    Kevin Jump
    0

    Hi I've had a look into this, and there is no (easy) way using the API that uSync does to stop the file portion of the template being overwritten when the database element is imported. 

    this might change as the API evolves in V6/7 but for now I would recommend if you work this way and still want to use uSync for other things that you turn off template and stylesheet syncing in the uSyncSettings.Config file - all you have to do is set the values to false in the elements section of the config 

        <Elements 
          dataTypes="true" 
          docTypes="true" 
          mediaTypes="true" 
          macros="true" 
          stylesheets="false"
          templates="false" 
        /> 
  • Stefan Bohlin 46 posts 168 karma points
    Aug 22, 2013 @ 11:17
    Stefan Bohlin
    0

    I had a look in your code and couldn't you at this bit import the content from the template file (if it exist) into the XmlNode:

                       XmlDocument xmlDoc = new XmlDocument();
                       xmlDoc.Load(file);

                       XmlNode node = xmlDoc.SelectSingleNode("//Template");

                        if (node != null)  {
                           Template t = Template.Import(node,user);

    This behaviour should be a setting in the config aswell i think.

    I guess you could do the same for stylesheets.

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

    Yeah . I've been thinking about it - I don't want to go to far from built in methods but this one is probably worth it. 

  • Stefan Bohlin 46 posts 168 karma points
    Aug 22, 2013 @ 11:28
    Stefan Bohlin
    0

    Definitely is. This "behaviour" is what is keeping me from using uSync as we always develop sites locally using our favorite editor.

    The hardest part is that i really want to use uSync as it's really awesome ;)

  • Kevin Jump 2309 posts 14673 karma points MVP 7x c-trib
    Aug 23, 2013 @ 13:29
    Kevin Jump
    0

    Looking at the Core code I actually think this issue was resolved for us in Umbraco v4.10.0 and umbraco 6.0.3

    the line that overwrites the desgin on import was removed from the file in response to bug U4-1009 and V4-1010

    so the core import function no reads

     public static Template Import(XmlNode n, User u)
        {
            string alias = xmlHelper.GetNodeValue(n.SelectSingleNode("Alias"));
    
            Template t = Template.GetByAlias(alias);
            var design = xmlHelper.GetNodeValue(n.SelectSingleNode("Design"));
    
            if (t == null)
            {
                //create the template with the design if one is specified
                t = MakeNew(xmlHelper.GetNodeValue(n.SelectSingleNode("Name")), u, 
                    design.IsNullOrWhiteSpace() ? null : design);
            }
    
            t.Alias = alias;
    
            return t;
        }
    

    which is because the line

            t.ImportDesign(xmlHelper.GetNodeValue(n.SelectSingleNode("Design")));
    

    was removed from below t.Alias = alias

    I've just tested this on 4.10.11 and indeed it does look like this is the case - so post v4.10.0 and v6.0.3 this issue appears to have fixed itself : ) I'll look at stylesheets next.

  • Stefan Bohlin 46 posts 168 karma points
    Aug 23, 2013 @ 13:32
    Stefan Bohlin
    0

    Fantastic!  ;)

  • Kevin Jump 2309 posts 14673 karma points MVP 7x c-trib
    Aug 23, 2013 @ 13:37
    Kevin Jump
    0

    for umbraco 4.10.11 - this is also true for stylesheets.

    the outstanding issue is that uSync only triggers on change events inside umbraco, so unless after editing a file in your editor you go into umbraco and save it uSync won't create the usync file needed to transport it to another installation.

    you can get around this by transporting the css / master page / views folder as part of your source control. as it would appear the behavior of umbraco is now only to write the contents on these file when they are being created for the first time.

    Kevin

  • Stefan Bohlin 46 posts 168 karma points
    Aug 23, 2013 @ 13:51
    Stefan Bohlin
    0

    Cool!

    I'll try it out ;)

Please Sign in or register to post replies

Write your reply to:

Draft