We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 188
    • 11 Posts
    I’m sorry if I’ve dropped in the wrong place but first I should say the following:

    Hello and what a great CMS, what a comunity.
    Ok its kind of slushy but its sincere.

    Got up and running in no time with my own template and stuff and was about to start looking at adding MODx tag but found the template I am working with is a bit sloppy in IE ( ha, theres a surprise) so I need to fix a couple of things before I move on. It was great that whenever I stumbled I found an answer here on the forum or in the docs.

    My question is this:
    I use Dreamweaver and would like to edit the page there and upload and so on with in DW. Now where the hell does MODx store the template so as I can grab it, work on it and send it back to the server, if this is possible of course. Checked the directory tree and stuff but can’t find the file.

    Any pointer greatly appreciated and I’m sorry if this is too noobish for words.

    Cheers
      • 26435
      • 1,193 Posts
      I do this all the time using a little snippet I got from Susan Ottwell (MODx user sottwell). I do not remember where she said she got it. Maybe it is from Etomite. Anyway, Here is the snippet. I have it saved in my manager as "Template".
      <?php
      if ( !isset($template_file) || $template_file == "" ) return "No file specified."; //check if there's a file given.
      
      ob_start();//Start the buffer
      
      include $template_file; //include
      
      $ob_contents = ob_get_contents();//get contents from the buffer
      ob_end_clean();//and kill/delete the buffer
      return $ob_contents;//return it to MODx.
      ?>


      Now, if I have my template files (CSS, images, and template.html) stored in /assets/templates/mytemplate/, under the Manage Resources->Templates tab, in the area where you would normally put the template code, I put this instead.

      [[Template? &template_file=`assets/templates/mytemplate/template.html`]]


      You would of course replace "mytemplate" with the name of the folder your template is in and "template.html" with the name of your template file.

      Now it is easy to edit the template because each time you update that file in dreamweaver and sync it with the server MODx reloads it’s contents from that file rather than from what is stored in the database. This probably adds some extra overhead, but makes it easy for modifying, refreshing, and checking the layout. Once you have it looking good, then it is a good idea to put the template code directly in the database, but this works great for tweaking your template code!

      -sD-
      Dr. Scotty Delicious, Scientist
        Husband, Father, Brother, Son, Programmer, Atheist, Nurse, Friend, Lover, Fighter.
        All of the above... in no specific order.


        I send pointless little messages
        • 188
        • 11 Posts
        Ah this loks interesting I shall have a go but I’m slowing down a bit - think I gotta cold coming :’(

        Thanks for that, I will come back and tell how I got on.
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          I got this code from Richard Mehaffey, MODx user scraf, a designer in the Netherlands that I work with.
            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
            • 188
            • 11 Posts
            I’m sorry man but I’m gett myself confused here

            You say you called the file template and saved it in manager - where ? I have more questions but it would be quicker if you could just the facts you did but as if you where giving the info to a complete idiot.

            Sorry to be a pain.
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              1. Make a new snippet in the manager, with the code from the snippet.
              2. Make a new template in the manager, and just put the snippet tags in it, with the path pointing to where you want to keep your template file.
              3. Make your template in Dreamweaver and keep it in the directory you specified.

              That’s all. Really, all it does is "include" your template file; nothing fancy there at all.
                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
                • 188
                • 11 Posts
                OK here what I have done - oh and please keep in mind that I got to the point where I was about to discover mODx tags when I decided that the template needed working on and I would like to do it in DW. So at the risk of bringing your wrath down upon me --

                Made a file called template.htm which contained the first load of Code Scotty Delicious gave me. I saved this in the Snippet directory.
                Next I made a template called template in the resources manager area and slapped the snippet in that remembering to check the path and change the name of the template file to my own which is lx360.html.
                Finally I uploaded lx360.htm

                Then my connection bombed out on me! >:(
                20 damned minutes

                So now I’ve lost track of where I was at but am I on the correct lines -I’m getting 404’s at the mo so I don’t know if its me or the connection bomb
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  No. In Manager->Manage Resources, in the "snippets" tab, create a new snippet with the PHP code Scotty gave you. The assets/snippets folder is only for auxiliary include files a complex snippet may need (like the eForm or WebLogin snippets).

                  Then in the "templates" tab make a new template, but only put the snippet call there. That snippet call will cause the real template file (wherever you keep it, assets/templates is a logical place) to be included.

                  If you give the new snippet the name Template, then:
                  [[Template? &template_file=`assets/templates/mytemplate/template.html`]]
                    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
                    • 188
                    • 11 Posts
                    Thanks for coming back again I really appreciate it.
                    I think I have made a boob somwhere that is having a knock on effect so I may strip it back and start again.

                    I made a big mistake over snippets but have that understood now after you last post and just to show you here is what I am about o do step by step as I go along:

                    In Resources/Snippets I made a new snippet and added the Scotty code and saved it as template.
                    Then I made a new template and added the snippet call, here it is: [[Template? &template_file=`assets/templates/mytemplate/template.html`]]
                    I saved as template.
                    This I take it is OK as long as I remain true to the path I have stated in the snippet call.

                    Now in dreamweaver I have a template that I want to work on. I will also name it template.html - and save to assets/templates/mytemplate/

                    Done this but get a 404: The requested URL /public_html/assets/templates/mytemplate/template.html was not found on this server.

                    Not my day is it
                      • 28042 ☆ A M B ☆
                      • 24,524 Posts
                      Hm... wonder where that "public_html" part is coming from?
                        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