We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 16429
    • 254 Posts
    I find very useful to have an "utility" to preserve the value of TVs assigned to documents when the TV is modified.
    Ok, an example:

    Let’s have a TV ("Colors") dropdown list:
    Red
    Blue
    Green
    White
    Black

    Now we want to move from one TV ("Colors") to 2 TVs (let’s say "Colors" and "BlackWhite") with values:
    Colors
    Red
    Green
    Blue

    and

    BlackWhite
    White
    Black

    All the documents that had "white" or "black" values will fall to default one, and the value is lost.
    This can be a little problem when building the logical structure of a site before publishing or if you have few pages, but it’s a big mess if you have many pages. You have to correct every page at hand.

    What I mean by saying "preserve the value" is keeping white/black values after splitting the TVs. With, obviously, a way to reset in case you don’t want to keep the values.

    I hope you understand what I mean, anyway ask for more info as usual.
    Thanks!
      kudo
      www.kudolink.com - webdesign (surprised?)

      [img]http://www.kudolink.com/kudolinkcom.png[/img] [sup]proudly uses[/sup] [img]http://www.kudolink.com/modx.png[/img]
      • 22815
      • 1,097 Posts
      I would have to experiment to see exactly what happens when you remove black from "Colors". I suspect that the document continues to have black as the value of Colors until you load the page in the Manager - it can’t match black to any of the new available values and doesn’t display it - and on a subsequent save will be one of the newly trimmed set of values.

      I’m not sure at what point the system should figure out that Colors should be empty and BlackWhite should be Black. It is potentially dangerous to rely on the value being the same, as the TV meaning could be completely different.

      I believe that the solution involves going from 1 TV to 2 new TVs, rather than 1 reimagined TV and 1 new TV.

      If you renamed the existing Colors to ColorsOld and added Colors and BlackWhite, you would still see the old setting when you went in to manually set the new colours.

      Solution One
      You’d still need a tool, a Bulk TV Editor, but this would now be much more broadly useful. You could list all the TVs with a ColorsOld of Black and set their BlackWhite to Black, and so forth.

      Solution Two
      In some way set the default starting value of BlackWhite to be the value of ColorsOld, if valid. Repeat with Colors.

      Solution Three
      An actual "split TV" facility.

      Once all the values had been stored in new locations, you could ditch ColorsOld.
        No, I don't know what OpenGeek's saying half the time either.
        MODx Documentation: The Wiki | My Wiki contributions | Main MODx Documentation
        Forum: Where to post threads about add-ons | Forum Rules
        Like MODx? donate (and/or share your resources)
        Like me? See my Amazon wishlist
        MODx "Most Promising CMS" - so appropriate!
        • 16429
        • 254 Posts
        I had a DropDown TV (listing product genres) with 64 values: building up the site I needed to split it in 4 macrocategories, 1 was the same TV (with less options), and 3 were added (each with a group of genres token away from the old one).

        Those documents which values pertain to the old TV (only edited) retain the same value, if the value still exist (or fall to default if the value doesn’t exist any more).
        Those documents which values were stripped and added to a new TV lost values.
        I think a way to prevent this can be very useful.

        I would think about writing something for it if the documentation about creating plugins and modules were a bit deeper than now.

          kudo
          www.kudolink.com - webdesign (surprised?)

          [img]http://www.kudolink.com/kudolinkcom.png[/img] [sup]proudly uses[/sup] [img]http://www.kudolink.com/modx.png[/img]
          • 6726
          • 7,075 Posts
          +1 here, I have been thinking about that lately...

          My last project involves a lot of TVs used to store custom content and one of the longer term issues is just what you describe. At first I wondered if using an @INHERIT binding could not work, but it would make things awful unpratical... Another thing which came to mind is use some SQL, but again that would be unpractical...

          I am curious as to what kind of solution could be reached to solve this...
            .: COO - Commerce Guys - Community Driven Innovation :.


            MODx est l'outil id
            • 16429
            • 254 Posts
            Mmm... storing the old values in the DB in something like a versioning system?
              kudo
              www.kudolink.com - webdesign (surprised?)

              [img]http://www.kudolink.com/kudolinkcom.png[/img] [sup]proudly uses[/sup] [img]http://www.kudolink.com/modx.png[/img]
              • 6726
              • 7,075 Posts
              I know it doesn’t help the present situation, but versionning will ship with 1.0 smiley
                .: COO - Commerce Guys - Community Driven Innovation :.


                MODx est l'outil id
                • 30223
                • 1,010 Posts
                In the current state MODx is in I’d approach this problem like this:

                Create 2 (or more) new TV’s instead of re-using the existing one.
                I’d leave the existing one as is but not assign it to any template. That way nobody can use it accidentally but existing values would remain in the database.

                In the default values of the new TV’s I’d use an @EVAL binding which would check the site_tmplvar_contentvalues tables for a value for the old TV and If found, use that value. If not use the default value of the new TV.

                This should give you the behaviour you’re after as far as I understand.
                If someone edits a page which has one of the new TVs but a value from the old TV, but that someone does not assign a new value, the old value (of the old TV) would remain on saving the page. Once you were certain that all pages contain values for the new TVs you could delete the old TV and change the @EVAL binding for the deault values.

                  • 6726
                  • 7,075 Posts
                  I wouldn’t have thought of using @EVAL (never used it, in fact... @bindings are not that easy to grasp and doc is not quite there yet too...).

                  Thanks for the idea, if it were to works, that would make my life easier !
                    .: COO - Commerce Guys - Community Driven Innovation :.


                    MODx est l'outil id
                    • 28042 ☆ A M B ☆
                    • 24,524 Posts
                    @EVAL makes the TV work just like a snippet.
                      Studying MODX in the desert - http://sottwell.com
                      Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                      Join the Slack Community - http://modx.org
                      • 16429
                      • 254 Posts
                      Quote from: TobyL at Aug 21, 2006, 09:39 PM

                      Once you were certain that all pages contain values for the new TVs you could delete the old TV and change the @EVAL binding for the deault values.

                      Sure your way is very near to a solution, but it doesn’t eliminate the need for a page-by-page correction.
                      By the way I’m sure this will absolutely do the work, and thank you for the enlightening advice.
                        kudo
                        www.kudolink.com - webdesign (surprised?)

                        [img]http://www.kudolink.com/kudolinkcom.png[/img] [sup]proudly uses[/sup] [img]http://www.kudolink.com/modx.png[/img]