We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 43092
    • 11 Posts
    Can I access templates, chunks and snippets through FTP? If so, where are they located in the file structure?

    I would like to edit them using tools like Aptana.

    Many thanks,
    Luke
      • 22840
      • 1,572 Posts
      Hi Luke,

      In answer to your question no you can't as there tables in the database, there are a few addons for code editors but it will depend what version of MODX you are running to which one is best for you.
        • 40092
        • 265 Posts
        Out of the box, you can't.

        I use a 'loader' snippet for that. Create a snippet, name it FileLoader (or anything you please)
        Insert:

        <?php
        require("assets/snippets/".$name."/index.php");
        ?>

        Where name is the name of the folder your snippet is in. (e.g. assets/snippets/mysnippet/index.php)

        Now you can put the contents of that snippet in an index.php file in that folder and you can access by ftp and edit in your favorite editor.

        change the path if you wish to something that suits you.

        And wherever you need the template or snippet you can make a call to it:

        [[FileLoader? &name=`mysnippet.php`]]
          • 3749
          • 24,544 Posts
          I think this might be more reliable:

          <?php
          return require "assets/snippets/".$name."/index.php";


          And you should leave out the closing php tag. Also, once it's working, change require to include.
            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
            • 24629
            • 370 Posts
            when you want to dit your own snippets, templates and chuncks you can make a static resource of them and use aptana to edit and upload to the server. works perfect

            Ralph
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              If you are using Evo, you will need snippets to "include" your external files. If you are using Revo, you can use static elements. Static elements simply contain the path to the file.
                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
                • 40092
                • 265 Posts
                Quote from: sottwell at Mar 16, 2013, 04:38 PM
                If you are using Evo, you will need snippets to "include" your external files. If you are using Revo, you can use static elements. Static elements simply contain the path to the file.

                Well, i guess i'd be showing my Evo habits here ;-) Is there some documentation on that?
                  • 18373 ☆ A M B ☆
                  • 3,141 Posts
                  Quote from: thapriest86 at Mar 16, 2013, 05:45 PM
                  Quote from: sottwell at Mar 16, 2013, 04:38 PM
                  If you are using Evo, you will need snippets to "include" your external files. If you are using Revo, you can use static elements. Static elements simply contain the path to the file.

                  Well, i guess i'd be showing my Evo habits here ;-) Is there some documentation on that?

                  Found a lil' bit here: http://rtfm.modx.com/display/revolution20/Upgrading+to+2.2.x#Upgradingto2.2.x-StaticElements

                  It's mostly just create a new element and pick the file. It then syncs the contents of the file to the database and pretends it's nothing different from a regular element. Note that while it does sync the file contents to the database, it does not clear the resource cache, so you will have to clear the cache yourself if you need a cached snippet tag to change after changing the snippet in the file.
                    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.
                    • 28042 ☆ A M B ☆
                    • 24,524 Posts
                    One irritating little "gotcha" I ran into while using this feature in my MODXpo workshop was when converting an existing element into a static element; for example converting the existing default template to use an HTML file from a downloaded free template. I was converting it to static, deleting the existing content, then saving. Thus saving the empty content to the file! So it's very important to keep in mind that the feature works both ways... what you save in the Manager gets written to the file. If you have the template open in the Manager, changing the file via FTP won't automatically change what's in the Manager's content field, and you need to refresh the Manager page to get the new file contents.
                      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
                      • 3749
                      • 24,544 Posts
                      I've destroyed files more than once because of that "gotcha." If you use static elements, it's critical to have a current backup of the files. I use Git and commit often.

                      MODX should really warn you if you try to save an empty static element when the file is not empty.
                        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