Copied to clipboard

Flag this post as spam?

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


  • John Bergman 483 posts 1132 karma points
    Sep 08, 2017 @ 22:54
    John Bergman
    0

    Refactoring Documents

    Can anyone provide some guidance as to the best way to do some document type refactoring?

    Specifically the following operations

    Moving one or more fields to a parent document template

    Extracting one or more fields to a new document type and updating the document that was extracted to use the new document type via composition

    Reparenting a document template to a new parent

    Renaming a Document Template (the internal name, not just the visible name)

    Renaming a field (the internal name, not just the visible name)

    We have grown to a fairly large set of documents, and would like to make some adjustments to the CMS to simplify the structure/implementation. Unfortunately, I don't really see (or haven't been able to find) the processes for doing this without completely disrupting the content already present in the CMS.

    Any pointers are GREATLY appreciated!!

  • John Bergman 483 posts 1132 karma points
    Sep 13, 2017 @ 01:23
    John Bergman
    0

    Anyone?

  • Kevin Jump 2348 posts 14896 karma points MVP 8x c-trib
    Sep 13, 2017 @ 07:10
    Kevin Jump
    2

    Hi John,

    As you have probibly discovered most if not all of them are not really supported by umbraco out of the box - mainly because they change data structures - there are some hacky ways to do some of them. but

    Renaming a document template (internal name)

    This one should be doable in umbraco but you will need to republish all the content that relies on the document type once it is renamed.

    Renaming a Field (internal)

    Again like above if you republish all the content this should be fine

    .

    OK the hacky stuff: You can do the following with uSync & uSync.ContentEdition - but be warned this is hacky, i wouldn't do it on a live site or deploy to a live site without some testing, if these go wrong you will loose content.

    Make sure you have a full usync export (including content) before you start any of this (so insall usync & usync.contentedition and do a full export from the dashboard in developer)

    Reparenting a document template (assume doctype but the principle is the same for other things)

    if you go to the file usync creates for the doctype (usync/data/documenttypes). and open the parent one too. you can add the parent structure.

    from the new parent type note the key and Name values

    <Key>89a7eaca-cb97-413d-a90e-b8102f18a295</Key>
    <Name>My New Doctype parent</Name>
    

    then in the doctype you want to be parented by this doctype add the following to the Info section.

    <Master Key="89a7eaca-cb97-413d-a90e-b8102f18a295">myNewDoctypeParentness</Master>
    <Compositions>
      <Composition Key="89a7eaca-cb97-413d-a90e-b8102f18a295">myNewDoctypeParentness</Composition>
    </Compositions>
    

    (don't delete any other Compositions you may have at this point)

    run a import on usync, refresh the doctype tree and the doctype will move parents.

    that should work fine unless there are clashes in property names where the parent has the same ones as the new child, then it will fail

    Moving fields

    this is harder, if you delete a field in umbraco (to move it) then umbraco will delete all the content assocated with it. this is why you also need uSync.ContentEdition so you can put the content back.

    first find the usync file for the doctype you want to move the property from.

    in the Generic Properties section of the file you will see the property details, something like this

     <GenericProperty>
          <Key>39ba11c3-f74c-45f1-81d7-f4c5279fb6f1</Key>
          <Name>My Content Item</Name>
          <Alias>newContentItem</Alias>
          <Definition>0cc0eba1-9960-42c9-bf9b-60e150b429ae</Definition>
          <Type>Umbraco.Textbox</Type>
          <Mandatory>false</Mandatory>
          <Validation></Validation>
          <Description><![CDATA[A New Content Item]]></Description>
          <SortOrder>2</SortOrder>
          <Tab>Content</Tab>
        </GenericProperty>
    

    cut that from the source doctype, and paste it into the file of the doctype you want to move it too.

    when you do this change the Key value (to a new guid) - i am not 100% sure you have to but you are basically deleting and creating a new property so best to do that.

    run uSync import - you will get a clash message enter image description here

    Run the import again, and the property will go in the second time.

    at this point you will have the new property in the right place, but all the content from it will be missing on your site! - so again in usync if you run a full import (button on the right) all your content will be imported and as the usync content files will still have the content value in they will put it back onto the site for you.

    All That will work (if your careful) its a bit of a hack. Personally if it's loads of changes I would think about building a new site, but i know it depends on how much content you have etc. so this might be better for you..

  • John Bergman 483 posts 1132 karma points
    Sep 17, 2017 @ 18:34
    John Bergman
    0

    Kevin, are you suggesting exporting everything via uSync and editing the resulting Xml files and reimporting?

Please Sign in or register to post replies

Write your reply to:

Draft