We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 12983
    • 108 Posts
    I see there’s still no reply from devs on this (maybe it’s an elaborate one) so I advance my proposal.

    I anticipate that my suggested approach needs a core change because I need an editedon field in elements’ db tables, so that creating/updating an element should also fill that field in the database (I need to know WHEN an element has been created/updated).

    That said, it could be feasible to create a plugin, running e.g. OnParseDocument and OnManagerAuthentication (or something like that), that does some synch work between an ad-hoc Structure in the FileSystem (let me call this the "sfs"), and the modx database.

    It should retrieve:
    - the update timestamps of the elements from the db
    - the update timestamps of the elements from the sfs

    Then it will compare them, and take action accordingly: the rule is to automatically create/update the freshest elements; i.e. if it finds that chunk "whatever1" in db has a timestamp greater than the chunk "whatever1" in sfs, it must update the chunk file in the sfs. Otherwise, the reverse.
    Similarly, if it finds that snippet "whatever2" exists in sfs but does not exist in db, it must create the snippet in the db according to the data it will be able to read from the "whatever2" snippet file on the sfs.

    Filenames in the sfs have not to be the same of those in db, because the "real" names, as long as other stuff, has to be all contained in the file contents. Of course, as a convention, it will be convenient to assign in the sfs filenames at least similar to the corresponding "real" ones, just to recognize them easily when looking into the sfs folders.

    As a convention, elements will be only deleted from sfs (not from manager UI), so that the plugin knows that if it finds e.g. template "whatever3" in db but not in sfs, it means it must DELETE it from the database; while if it finds e.g. tv "whatever4" in sfs but not in db, it means it must CREATE it in the database. This approach assumes that the main development cycle is done through the sfs (with beloved IDE, version control and so on), but apart from the delete convention just declared, there’s no problem in using both the sfs and the manager UI, interchangeably, as long as timestamps are there to let the plugin know what’s new and what’s not.

    The "sfs" I’m speaking of is something like this on the filesystem:
    elements
    	chunks
    		chunk1.html
    		chunk2.html
    		...
    	snippets
    		snippet1.php
    		snippet2.php
    		snippet3.php
    		...	
    	...
    

    (note the file extensions for proper syntax highlighting in the IDE)

    If you open e.g. chunk1.html in the text editor, you find a data format like something that the plugin should be able to parse:
    <!--
    [comment]
    This text won't go into the database. It's just a comment visible in this file on the filesystem.
    So here I am writing some stuff I have to remember related to this chunk that I don't want those others with access to the manager UI care to read.
    First, this chunk has been developed just for test purpose, but it could also be used to..... yadda yadda.....
    
    [attributes]
    name = "chunk 1"
    description = "just a test chunk"
    category = "my chunks"
    clear_cache_on_save = true
    
    [properties]
    ...
    ...
    -->
    <div id="spf_response">
    <h3>[[+spf-thank-you]]</h3>
    [[+spf-came-from]]
    [[+spf-back]]
    </div>
    


    The create/update actions on modx db should be taken by using directly the scripts in:
    core\model\modx\processors\element

    The plugin of course should create that kind of files in the sfs when it needs to create or update a fresh element found in the database.

    This plugin could be active on development and on production environment, but on production the behaviour should inhibit the synch from db to sfs, allowing only from sfs to db. This way, the synching between development server and production server could be done by updating the sfs from development to production, and multiple development servers could be managed with version control on the sfs stuff.

    What do you think about this? Am I missing something? (maybe)
    • Quote from: insert_nick at Oct 18, 2009, 03:00 PM

      What do you think about this? Am I missing something? (maybe)

      Yep. tongue

      They are talking about what is beneath the surface.
      "The iceberg of ModX."

      Can’t wait to read further reply. I’ve noted this thread.
        Rico
        Genius is one percent inspiration and ninety-nine percent perspiration. Thomas A. Edison
        MODx is great, but knowing how to use it well makes it perfect!

        www.virtudraft.com

        Security, security, security! | Indonesian MODx Forum | MODx Revo's cheatsheets | MODx Evo's cheatsheets

        Author of Easy 2 Gallery 1.4.x, PHPTidy, spieFeed, FileDownload R, Upload To Users CMP, Inherit Template TV, LexRating, ExerPlan, Lingua, virtuNewsletter, Grid Class Key, SmartTag, prevNext

        Maintainter/contributor of Babel

        Because it's hard to follow all topics on the forum, PING ME ON TWITTER @_goldsky if you need my help.
        • 12983
        • 108 Posts
        Btw, if I understand well, as long as static elements pop out at some point, all my above post and further related discussions become garbage. Is that right?
        • Quote from: insert_nick at Oct 18, 2009, 03:00 PM

          I anticipate that my suggested approach needs a core change because I need an editedon field in elements’ db tables, so that creating/updating an element should also fill that field in the database (I need to know WHEN an element has been created/updated).
          ...

          What do you think about this? Am I missing something? (maybe)
          I don’t think any core modification is necessary here, but changes already planned for the 2.1 release include having a complete set of Audit fields on all transactional tables, including createdon, editedon, and deletedon time stamps, as well as createdby, editedby, and deletedby ownership. There will also be a transition to storing proper datetime types (vs. unix timestamps) during this period. We would implement this sooner, but it is part of a transitional plan to ween users off of interacting with the MODx data via direct sql calls; we want to introduce the new OO API and get component developers using these new APIs with only minimal changes to the core tables in 2.0, so we can transparently start optimizing and improving the data structures for 2.1.

          There are a number of significant structure changes that will be going on behind the scenes in 2.1 development that have been part of the original Revolution prototype since it’s inception. Our decision to implement the changes in this order are to reduce rejection among early adopters by providing as much compatibility with legacy components as possible. A few simple migration steps should allow existing custom component developers to get their sites working in 2.0 with minimal code changes (if any).

          I will make a suggestion that the new Registry service that comes in the MODx Revolution core can serve as an audit log for any object that you modify through the API (using a hook on all xPDOObjects which you can utilize to override behavior on various methods like save() and remove()), as well as a central communication mechanism for having file system-to-db synchronizations occur efficiently via Plugins. Let’s create a new thread to discuss this solution in detail, which I believe can be fully implemented as a MODx Core Extension without any significant core modifications (though it may produce some new ideas for or improvements to core API functions that need to be implemented, which is always good).
          • Quote from: insert_nick at Oct 18, 2009, 05:35 PM

            Btw, if I understand well, as long as static elements pop out at some point, all my above post and further related discussions become garbage. Is that right?
            Not at all; static Elements are similar to static Resources. The field that typically contains your source content simply points to a physical file containing the source content instead. All of the properties stored in the database for each Element or Resource are not saved on the file system, which is a key difference. However, serializing and storing this data on the file system is exactly what Transport Packages (a concept of serializing data from the database in a database agnostic format, along with file system resources, for packaging, distribution, and install automation purposes) do, so setting up a Core Extension to provide this specific approach to synchronizing both editable source content and database properties between the core database and file system is completely viable using these techniques, and could work in conjunction with or despite Static Elements depending on your needs.
              • 12983
              • 108 Posts
              Quote from: OpenGeek at Oct 18, 2009, 06:34 PM
              Let’s create a new thread to discuss this solution in detail, which I believe can be fully implemented as a MODx Core Extension without any significant core modifications (though it may produce some new ideas for or improvements to core API functions that need to be implemented, which is always good).

              Ok, done.