We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 13226
    • 953 Posts
    So, I am now taking the plunge into Revo after 8 years of Evo

    I have read a lot of the documentation and found the basics to be pretty much based on Evo

    Now that I am ready to start a test run I came a cropper big style.

    After going through the docs to find all of the elements I use for templateing I started to create my templates and chunks.

    Each time I saved a chunk the manager pulled in the info that was in the corresponding file into the "Chunk code" pane - me thinking this is just to show what was in the file, thought OK, nice trick, now delete the preview, as I don't want the info in the DB or any cache files (presuming it works the same as Evo)

    After sitting here for about two hours, creating multiple templates and chunks I thought, now is the time to see how the site looks in the front-end - WOW, nothing there.

    So, what now - checked the chunks in the manager and all there, mmmmhhhhh, what could be wrong here, I thought.

    Checked the files, made sure I hadn't deleted any or moved any by accident, all there

    Double checked everything again - all there

    Then I noticed the file size of the static elements "0kb" - opened the files in my friend Dreamweaver, and yes, you guessed it - no code.


    So, learning the hard way:

    The "chunk code (html)" preview, is not a preview, it's a place to modify the static page - where is the corresponding documentation for this pane ?

    "lock chunk for editing" - the crown jewel, whats the point of this when as an admin you can still delete stuff


    Thoughts:

    I use versioning for static files - simply as a security measure (backtracing + backups)

    The static files (chunks, templates etc.) on my live server(s) are all "read only - chmod 400" as no-one needs to modify them on the server and in case of a security breach they are less prone.

    My personal thought on this - why is this function needed, a static page / element should be modified outside of the system, not via the system.

    Is the code in the static files also copied into the DB - when yes, why ? The whole point of static pages is to not have them in the DB or am I thinking in the wrong direction ?

    UPDATE:

    I just set one of the static files to read only on my local server and now the manager underlines the "static file" select element in red and a pop-up says that the file is not writable and that the file can't be modified via the manager.

    This doesn't help much as the files need to be writable on the local server

    yes, I know, before anyone says - now you know, don't modify it in the manager - that's not the point, the point is, what does this actually do, save to DB, save to cache etc. and if the answer is yes, why [ed. note: iusemodx last edited this post 9 years, 11 months ago.]
      • 3749
      • 24,544 Posts
      Nothing says you have to modify the files of static elements in the Manager, but (as you found out) if you do and then save them, you're updating the disk files. You're definitely not the first person to lose work with static elements. wink

      If you modify the static element files outside of MODX, you should see the updated version the next time you load the element in the Manager.

      AFAIK, the content of static elements is not saved to the DB (though I've never checked), but the view in the Manager *is* a view of the disk file. On a remote site, it's not always convenient to edit the element files, so you have the option of editing them in the Manager, and using a lightweight code editor like Ace on them.
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 13226
        • 953 Posts
        @ Bobray

        Thanks for the feedback

        Nothing says you have to modify the files of static elements in the Manager
        I must have been modifying my post as you were typing smiley see "update"

        you should see the updated version the next time you load the element in the Manager.
        I create them once in the manager and they are never viewed again, as I use the static files only, so no need to view them again in the Manager

        You're definitely not the first person to lose work with static elements.
        I can imagine - I still haven't found documentation on this, which is in my opinion a definite lack

        so you have the option of editing them in the Manager, and using a lightweight code editor like Ace on them.
        I handcode all my HTML + CSS - I use dreamweaver as a fancy text editor
        • Static Elements are the exact same as regular elements, but with Static Elements their content is synced with the file you chose/set
          up. You can edit them both in the manager and on the file system - editing in the manager will update the file, and updating the file will update the database + cache next time the static element is retrieved by MODX

          This means that yes static elements have their content stored in the database, and yes their contents will make its way into the cache. As for why? Probably to make sure static elements did not need a bunch of extra code for processing when it should behave the same way as non-static elements. If static elements would bypass the database and cache entirely, it would need to be retrieved differently across the core, parser, extras etc.. while right now it's behaviour is exactly the same as non-static elements, which makes it easier to work with.
            Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

            Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
            • 13226
            • 953 Posts
            Quote from: markh at Apr 29, 2014, 11:26 PM
            This means that yes static elements have their content stored in the database, and yes their contents will make its way into the cache.

            So what is the point of having static elements when they are going to be in the DB anyway ?

            OK, I've found a "pro" myself - it's a lot quicker to use a static element as to login and modify the element in the manager - simply because the system is slow.
              • 13226
              • 953 Posts
              I have just further tested

              I have just deleted the content of one of the templates via the manager, BUT, the static file has not been modified

              I also modified the content of another template via the manager and again - no change to the static file

              I just closed everything down, deleted the full contents of the "core/cache" folder cleared all sessions and cleared browser cache - closed browser and started from scratch.

              Logged in to the manager - the template code in the manager has not been updated and the static file still has its code.

              So, is this a chunk thing or should all static files be modified when modified in the manager ? [ed. note: iusemodx last edited this post 9 years, 11 months ago.]
              • Quote from: iusemodx at Apr 29, 2014, 11:32 PM
                Quote from: markh at Apr 29, 2014, 11:26 PM
                This means that yes static elements have their content stored in the database, and yes their contents will make its way into the cache.

                So what is the point of having static elements when they are going to be in the DB anyway ?

                OK, I've found a "pro" myself - it's a lot quicker to use a static element as to login and modify the element in the manager - simply because the system is slow.

                The point is that you're able of editing them outside MODX - in your code editor of choice smiley That's the goal of the feature and what it accomplishes.

                As for the files not updating when you make changes in the manager, you mentioned changing write permissions, perhaps you need to re-enable that again?
                  Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

                  Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
                  • 13226
                  • 953 Posts
                  Quote from: markh at Apr 30, 2014, 12:08 AM
                  As for the files not updating when you make changes in the manager, you mentioned changing write permissions, perhaps you need to re-enable that again?

                  These templates were not modified. They have full read write permissions
                    • 14646
                    • 8 Posts
                    Static elements are a also great if your working with version control such as git. Now you templates, chunks, and snippets can call be versions controlled along with your css and js.

                    Another use is when you have a live website and also a copy of that website running on your local computer for ongoing development. Finished making the changes to templates, chunks, and snippets? Upload the new versions of static files to the live server, clear the cache and the new changes are live.

                    Running MODX locally for development really is a huge time saver.
                      Jonathan Haslett
                      Director at https://dash.marketing/
                      MODX Slack @jonathanhaslett
                      • 13226
                      • 953 Posts
                      @Jonathan Haslett

                      I don't mean to sound ungrateful for your answer, but if you read my post(s) you will see that I do use the static files for version control and that I develop on my local server and when finished upload to the live server.