We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 46971
    • 33 Posts
    Hey,

    I want to work with my own editor live on my server (ftp mounted on my iMac + CodeKit with Less files etc. + Adobe Brackets Editor). For manually coded websites this workflow works fine. But how do I get the CMS / Modx-based files to my server and what is the best solution to create a logic folder structure on my server.

    I've found the following folder structure in a video tutorial (attached). Do I have to create the folder on my own? Is such a structure recommended or does anyone have a better solution?

    To make a chunk static. Do I have to create the file on the server first and put the already written modx-code of the chunk in it? Then make the chunk static - link it to this created file (with the identical code) and thats it?

    Hope you guys can help me getting started with static files / working on my server. Thank you!
      • 17301
      • 932 Posts
      Hi dsquare,

      Could you upload the files to imgur and link them here? There's an ongoing issue with attachments on this forum at the moment.

      In terms of working with static files what I do personally (and again unable to see your attachment) is to setup various media sources to hold snippets, chunks, templates etc as per this image:

      http://imgur.com/GzJ5SnX

      Chunks are just setup as .tpl files and in my controllers media source i have a file called template.tpl with this content:
      {set $properties['tpl'] = $_modx->getPlaceholder('template.tpl')}
      {if empty($properties['tpl'])}
      {set $properties['tpl'] = "default"}
      {/if}
      {include "file:templates/tpl/{$properties['tpl']}.tpl"}


      Then all I need to do is create a template in the elements tab with the following code also:
      {set $properties['tpl'] = $_modx->getPlaceholder('template.tpl')}
      {if empty($properties['tpl'])}
      {set $properties['tpl'] = "default"}
      {/if}
      {include "file:templates/tpl/{$properties['tpl']}.tpl"}


      In the properties tab of my template I have a property called tpl with a value of what my template is called so in the below example im referencing a folder called recipe with a template of recipe.

      http://imgur.com/TCkxdI7

      Once that is all setup you can work locally and just have your processor push to the server and also comit to a repo.
        ■ email: [email protected] | ■ website: https://alienbuild.uk

        The greatest compliment you can give back to us, is to spend a few seconds leaving a rating at our trustpilot: https://uk.trustpilot.com/review/alienbuild.uk about the service we provided. We always drop mention of services offered by businesses we've worked with in the past to those of interest.
        • 3749
        • 24,544 Posts
        To make a chunk static. Do I have to create the file on the server first and put the already written modx-code of the chunk in it? Then make the chunk static - link it to this created file (with the identical code) and thats it?

        I think if you mark the chunk as static in the Manager, put in the path and filename, and then save it, that will be enough, but I haven't tested this lately.
          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
          • 24374
          • 322 Posts
          Quote from: BobRay at Aug 26, 2017, 11:32 AM

          I think if you mark the chunk as static in the Manager, put in the path and filename, and then save it, that will be enough, but I haven't tested this lately.
          Yes, that's what I do. I use static chunks, snippets, and templates exclusively. Typically, I create the file in my editor, upload it to whatever folder I've created for these on the server, then add the snippet/chunk/template in modx, click on static resource, then select the file I just uploaded. Using a custom media source is optional; sometimes I just leave the media source on "File System". From then on, it's simple: edit file on my computer, upload to the server and I'm done.
            • 46971
            • 33 Posts
            Yes, it works, when I save the chunks as .tpl files on my ftp server - in any folder - and make the chunk in modx static. But it does not work with modx-templates. When I save it on my server and make the modx template static + link it to the file, modx seems to create a new file on my ftp called "templateNAME.tpl". But the modx template gets empty and the website does not work anymore.

            So with chunks no problem, but with templates something went wrong.

            Another question. Is it possible to change the code in the modx chunk, too - though it's static now?
            Or do I need to change it on my ftp server now, every time? So I need to decide wether its static or not? - It would be great to change some things in the modx backend by time.. though most time I would like to work on the server.

            Or do I need to change the file under "files" and not under "elements" anymore?
              • 3749
              • 24,544 Posts
              You can change the chunk (or other element) in the Manager and save it. That will change the file.

              I think there are some editors that will "synchronize" the files (I believe PhpStorm does this) based in their dates so you can update files locally or on the remote at will.

              TBH, I create a whole local site based on the remote using XAMPP for the local server and DB, then I work locally, using Git to record changes, and cut-and-paste to the remote. I never use static files.

              It's often a pain to get the local site working, but you only have to do it once.

              MODX doesn't care where you put the static files, BTW, they can go anywhere as long as the path is correct.

              I don't have an answer to your question about Templates. It sounds like a bug. Remember, though, that although MODX doesn't much care about the case of Template names, static filenames are case-sensitive on most remote servers and not on local Windows platforms (not sure about Mac).
                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