We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 1100
    • 20 Posts
    Hi All

    I’m a noob with MODx although i’ve used a couple of other cms’s (jomla-mambo) but i am initially stumped when creating a new template. I’ve been following the ’Creating Unique Templates For Your Site’ tute in the Template Basics area on the modx site, but I have run into the following catch 22 predicament:

    1: when i create a new template where does it actually ’live’ within the template directory structure? I can see the default templates in the windows directory structure but not my new template, and i can see my new template it in the MODx ’Manage Resources’ area so i know it exists.
    2: assuming i can get clear with question 1, how do i attach my stylesheets?

    For the record, I’ve created the following directory structure to house custom templates css and graphics respectively:
    htdocs\modx_01\assets\templates\test
    htdocs\modx_01\assets\templates\test\css
    htdocs\modx_01\assets\templates\test\grfx

    All well and good but i can’t see this reflected in the admin interface.

    I hope I’ve written this clearly enough... any and all help would be very appreciated as I want to get moving!
    thanks
    a-a
      • 25307
      • 114 Posts
      You have to insert the html for the template from within the MODx manager. Take advantage of the MODx Team’s KILLER documentation of the system whenever possible - honestly some of the most well written usage and customization documentation I’ve seen for a CMS/CMF.
      Here’s a good place to start for creating a custom template -> http://modxcms.com/template-basics.html
        • 25663 MODX Staff
        • 12,272 Posts
        First, do read the documentation. While it may be a bit out of date, lots of stuff will be explained and you’ll get a better feel for how MODx works. And it is much different than other stuff out there! http://modxcms.com/documentation.html

        Then peruse http://wiki.modxcms.com

        To specifically answer your question, MODx templates are stored in the database. They reference things on the filesystem. So if you wanted to put a call to your css file in the templates folder, you’d simply add this to your template:
        	<link rel="stylesheet" type="text/css" href="assets/templates/test/css/site.css" />


        Lately, I’ve been abandoning the use of a lot of the folders in the assets directory and tend to just put my CSS at the top level of the assets folder and then use the existing images and js folders as needed. I tend to devlop my templates locally in Textmate as a static HTML page and this is the way I structure my local test folders, so it makes it dead-easy to migrate to MODx when it’s done.

        (Note: there are advanced things you can do like storing your actual template code on the filesystem, and using MODx pages for dynamic CSS, but those are advanced topics. Just keep in mind that MODx is incredibly flexible and there’s typically 3-4 ways to do any task, and usually in a way that you get comfortable with pretty quickly. smiley )
          Ryan Thrash, MODX Co-Founder
          Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
          • 1100
          • 20 Posts
          Thanks all for these replies
          I’ll get to work on these recommendations but It’ll have to wait a few hours as i’ve been waylayed somewhat.
          I must say that i find the method of adding the xhtml straight into the modx manager really functional, as opposed to ’other’ cms’s - it feels more ’hands-on’.
          Thanks rthrash for letting me know the template and css routes.

          just one more quick Q in lieu of returning to modx work:
          Say i’ve applied a new page to my template, in order to preview this page within the new template am i right in assuming i simply go to Site > Preview?

          Thanks,
          a-a
            • 30856
            • 21 Posts
            rthrash: I’ve read comments about your best practices before and been very intrigued.

            It appears you don’t use a template specific folder IN the master ’templates’ folder ?
            If this is so I am thinking it would be a good excercise to TRY to modify the MODxHost template to not using a folder.
            Would this be a good experiment. It has lots of things to it, .js etc.

            Also interested to know if many GURUs use a template for the homepage and another for the rest of the site.

            And, if using 2 or more template for a site I guess it would still be cool and ’svelt’ to keep all the parts as you already do.
            ie. CSS at the top level of the assets folder and then use the existing images and js folders as needed.


            I’m sure that like me alot of us here are VERY interested in BEST practices. Love to know more of the GURU’s tips.

            I kinda get frozen from doing much other that playing around as I’m aware that there’s usually ONE very best way to leaving most of the doors open, so to speak. [as regards file organization, TVs instead of chunks etc...]

            I would like to create the most flexible basic structure generally.








              • 25663 MODX Staff
              • 12,272 Posts
              Modifying the MODx host template should take about 2 minutes. Just move the files on the filesystem and change the links in the template header. You might need to udpate a few things in the JS and CSS files ... extending out to 5-10 minutes.

              I’ve also found that while I try to strive to keep the number of templates down, there’s frequently enough difference on the home pages that it’s just easier to have a different template for that. I always use the heck out of TVs and @INHERIT ... and chunks for lots of things including my doctype/meta content, navigation and footer.
                Ryan Thrash, MODX Co-Founder
                Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                • 30856
                • 21 Posts
                Whew.... talk about syncronicity... I was just trying that.... it DID take about 2 minutes!!!!
                unreal.... just changed the template HTML to point the obvious...
                then the tools/configuration update pages move...
                i’m stunned...
                the fog is clearing...

                now if I can just figure out a way to use phatfusion’s imagemenu in place of MODxHost’s menu.
                My post about this Quest: Currently in the top 10 sequentially in this forum ..... hehehe
                hmmmmm.....

                MODx Skool anyone? ::::-

                UPDATE COMMENT: 90 minutes later.... after a successful fumble with MaxiGallery i’ve partially [yet very successfully in documents at least] gotten things like phatfusion imagemenu and electricprism slideshow going.. now to actually UNDERSTAND what I’ve done and fine tuned from there.