Copied to clipboard

Flag this post as spam?

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


  • Søren Reinke 158 posts 206 karma points c-trib
    Jan 14, 2015 @ 16:21
    Søren Reinke
    0

    Updating every node containing a Grid.

    Hi there

    I need help to update nearly every single node on our company website.

    We decided to use Umbraco 7.2 on the day of the last Codegarden keynote, due to the amazing Grid system.

    Knowing using an alpha version is quite risky, but we where lucky, it just works :)

    But now i would like to update to the official 7.2.1 release of Umbraco.

    But i found 1 issue, i would rather solve in c# than having to update every single node by hand.

    In the alpha version there was a hidden angular variable/field called cssClass which i added a textbox for, so the editor could add extra classes per row in the grid to do some styling.

    In the final release of 7.2.x it was added as the possibility to add Settings and Styles per row/cell (much better). But the way the data is stored in the JSON for grid has changed, so now all my extra styling is gone :-(

    Here is an example of the old way a row was store, with the cssclass field:

         <theGrid><![CDATA[{
     "name": "1 column",
     "sections": [
       {
         "grid": 12,
         "rows": [
           {
             "name": "12",
             "areas": [
               {
                 "grid": 12,
                 "allowAll": true,
                 "controls": [
                   {
                     "value": "<h2>Velkommen til vores verden</h2>\n<div id=\"inject_logo\"></div>",
                     "editor": {
                       "name": "Rich text editor",
                       "alias": "rte",
                       "view": "rte",
                       "icon": "icon-article"
                     }
                   }
                 ]
               }
             ],
             "cssClass": "text-center"
           },

     

    Here is the same row from the same grid, but with the data stored in the new way:

       <theGrid><![CDATA[{
     "name": "1 column",
     "sections": [
       {
         "grid": 12,
         "rows": [
           {
             "name": "12",
             "areas": [
               {
                 "grid": 12,
                 "allowAll": true,
                 "controls": [
                   {
                     "value": "<h2>Velkommen til vores verden</h2>\n<div id=\"inject_logo\"></div>",
                     "editor": {
                       "name": "Rich text editor",
                       "alias": "rte",
                       "view": "rte",
                       "icon": "icon-article"
                     }
                   }
                 ]
               }
             ],
             "styles": {},
             "config": {
               "class": "text-center"
             },
             "id": "63fa548d-fe17-8f24-9f5f-9c333bc2e455"
           },

     

    In the old way it's just a field: "cssClass":"text-center", in the new way it is 2 fields, 'styles', and 'config', and there has been added an ID.

     

    How would i change the way that information is stored from C#? And adding the ID field?

    If i remember correctly there are about 400 pages, and i do not feel like doing it by hand :-)

     

    Thanks for your time ;-)

Please Sign in or register to post replies

Write your reply to:

Draft