We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 34162
    • 1 Posts
    How can I replace a document/folder with another one?
    I’m asking this since I think that with a replacement-function it would be possible to implement a common (and frequently needed!) workflow like this:
    1. Content is online, must be changed, but must be approved before publishing the changes
    2. Working copies are created - without changing or unpublishing the already published stuff
    3. Working copies are edited
    4. They are approved
    5. The new versions are published, replacing the old ones

    Creating copies is easy with MODx, but replacing seems to be impossible.

    To accomplish a replacement-function the following conditions must be met:
    1. A copy must store information (doc id) of its original
    2. DocIds must be "switched" between two documents when updating, so that the new version gets the id of the old one and the old one gets the id of the new. (the old version is then a kind of "backup")
    and
    3. Duplicating a doc more than once must be made impossible, since the value for the "original id" would not be unique anymore, causing problems when performing the "switch".

    How can this be done with minimal impact on MODx internal structures and working?

    To make this workflow perfect, it would be sufficient to have a user-role, which is a manager but has no access to the publish/unpublish/delete functions. And to have a more flexible status of documents (more than "published", "not-published" and "deleted": "to be approved" and "approved" should be added.)

    Any tipps, hints, experiences?
      • 6726
      • 7,075 Posts
      Yeah well, it seems to me that what you describe is not only workflow (which MODx lacks right now) but also revisionning. Right now we don’t have it with the 0.9.x branch, but 1.0 will have this natively, with rollback (go back to previous version), multi-lingual on top of that grin

      I know it’s not a satisfying answer to say "We’ll get this in the not-so-distant future" but it’s the case, and I don’t know how difficult it would be to build a plugin to do that with 0.9.x branch, but my guess is : a lot of work, not worth putting effort into it considering the 1.0/tattoo branch is not so far away...

      If jason (aka OpenGeek) drops by this thread and has some time, maybe he’ll discuss how this gets done with you...
        .: COO - Commerce Guys - Community Driven Innovation :.


        MODx est l'outil id
        • 34162
        • 1 Posts
        Hi wink
        Thanks for your honest reply. I didn’t thought that it would be that difficult to implement that in the 0.9 branch.
        But whenever you guys give me a reliable schedule, I’ll wait. That I’ve sent my complaints to Jason concerning all those "announcements without a date" doesn’t matter, as long as you guys come along with the long awaited stuff..
        And I will donate at least 10% of the first bucks I earn with MODX - REALLY, I will, I swear!
          • 6726
          • 7,075 Posts
          I didn’t know you had sent Jason something about this... Remember most of the time when the next branch is mentionned, it’s not an announcement, it’s updates on the project.

          The dev team is working real hard but they do have to make a living too, thus things are moving only as fast as they (humanly, and sometimes above that) can. You sure can’t question the great commitment of those guys (and gals, yeah Susan I don’t forget you wink ) and I am not even talking about their incredible talent and skills. I am not saying this because I am the marketing guy and part of the team : the release cycle is one of the shortest I have ever seen in an OS community, and most definitely MODx is groundbreaking in many ways.

          About making bucks with MODx, I have bet on it and my clients love it and I have more an more people consulting with me to build website with it ! This is a commitment you won’t regret grin About Donations : great, that will definitely help the dev process !!! I hope many will do like you intend to do smiley
            .: COO - Commerce Guys - Community Driven Innovation :.


            MODx est l'outil id
            • 34162
            • 1 Posts
            I can imagine the surhuman efforts it takes to bring MODx to the next stage - the stage where it can really show off its benefits. And, well, I wasn’t really complainin’ to Jason: it was just a remark concerning promises of that "we-will-solve-more-than-your-problem" type - but without providing details or a date. Gaining a community1, who is willing to learn&try, and emerging from this a community2, who is willing to share&donate: this might be the key factor for success. I’m in community1 right now and more than willing to join community2.
            Maybe it’s a good idea to seperate those two communities: One presenting things as they are right now, the other creating the future. And having donated could be the condition to be part of #2. I wouldn’t hesitate.
            If only half of the promises turn into reality it would be worth more than one donation...
              • 25663 MODX Staff
              • 12,272 Posts
              LOL... I’ve seen a lot of reality that is running customer sites, and I can say it’s dang cool. It very much IS a reality. wink
                Ryan Thrash, MODX Co-Founder
                Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                • 34162
                • 1 Posts
                Let’s get back to the topic:
                I just looked around in the manager and the source behind it. My idea was to use the "move page" functionality as a template for a "replace page". Instead of "newdocumentparent" I wanted to introduce something like "switchids".
                ("Click on a document in the tree to replace it with this page").
                The procedure itself would be fairly simple:
                1. get a new docID (just for temporary use)
                2. store the ID of the currentDoc (new content)
                3. store the ID of the replaceDoc (old content)
                4. set the id of the replaceDoc to the newID
                5. set the id of the currentDoc to replaceDoc
                6. set the id of the replaceDoc to currentDoc

                After all, I have the impression, that for this "poor man’s" versioning/workflow a module should be possible, and there would be no need to touch the core classes.

                Am I right??
                  • 25663 MODX Staff
                  • 12,272 Posts
                  You are indeed right. If you can get that working I will gladly make sure it makes it into the next rev. smiley
                    Ryan Thrash, MODX Co-Founder
                    Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                    • 34162
                    • 1 Posts
                    Cool! But I fear with this "subproject" I will have to dive into all that js-api php-db-api modx-manager manager-js manager-php modx-manager stuff. My chance to learn almost all about modx wink
                    Have to study the module-documentation once again...
                    Anyway: I guess it would be a very useful function, so I’ll give it a try - hoping that the forum and the team will help me out with some tipps when necessary. And it will be necessary, that’s one of the few things I know already. tongue