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

CSS

    • 40088
    • 708 Posts
    I'm a relatively new user looking for suggestions/feedback.

    I transferred a static site to Revo and the only thing left to move are the CSS files.Currently the files exist outside of MODX and I've been content to keep it that way. It's simple and it works for me so I don't feel compelled to change it. However, I've been wondering lately if by doing so I'm missing out on any useful features by not putting them under MODX control. I prefer to use an external editor so my guess is that the only way to keep doing it this way is to create a Template for each file and link to its static counterpart. Would that be correct? But are there benefits to importing static files instead? Not sure what's preferable.

    Thanks

    Revo 2.2.4
      Todd
      • 39932
      • 483 Posts
      There are benefits and drawbacks to both approaches. Largely it depends on how far you are willing to go in either direction.

      Static Files

      These files are not manipulated themselves by MODX and removed from security protocols that govern resources, making them faster to load, in general. The primary benefit to sticking with static files comes down to flexibility with external editing. Since the files themselves are typically uploaded, it doesn't matter what tools you use to edit them. My personal issue with this is that I consider Media Sources a security hole (not because they actually are, but they make me feel uneasy, nonetheless). I lean strongly toward database managed security, and that bias is reflected throughout this post.

      MODX Document Resources

      These files are in the database, and have all of the benefits that are associated with Resources. TVs, Custom Forms, MODX Tags, Snippets, etc. Anything that you can do with a MODX Document or Resource,, you may do with your CSS. Editing may still be performed with an external editor, but generally occurs via cut & paste, if using an external editor. A big bonus here is the MODX Parsing as you can apply colors or specific rules via a TV or System Setting (even User Setting). Another often overlooked possibility is using a Template (as you do not have to). I contend that the greatest benefit is database security.

      As MODX Document Fragments

      This is the approach that I personally use, via RO.IDEs (link in my sig). The idea here is to have the fastest editing while still maintaining flexibility and power of MODX parsing. I can find and edit any style faster than with any exernal editor. I can also search for class names, ids, or even specific rules using the Search Resources tool in the manager. The drawback here is extra resources and if not performed correctly, could increase the load of your page. However, the extra resources are literally as many or as few as you want. On my site, my CSS comprises 400+ micro-resources. I could just as easily do it in 4, but I need the extra resources.

      Turning off a single or group of styles takes literally the click of a button. Moving styles is literally drag-and-drop. This makes debugging CSS a dream for me. Each segment of my CSS is as protected or free as I want it to be without having to worry about Media Sources, or .htaccess, etc.

      Finally, I have a front-end AJAX editor for my CSS that blows external IDEs out of the water for managing my CSS.

      As MODX Static Resources

      This provides a good blend of MODX Parsing and external editor support. But you may include MODX Tags and they will be parsed. The only real limitation is that the object code is not actually in the database. While this is a big deal to me, others consider this not a big deal. Additionally, while it provides database managed security, the static file is still accessible if you either a) want it to be, or b) are not careful. (There's that bias again). [ed. note: fuzzicallogic last edited this post 14 years, 1 month ago.]
        Website: Extended Dialog Development Blog: on Extended Dialog
        Add-ons: AJAX Revolution, RO.IDEs Editor & Framework (in works) Utilities: Plugin Compatibility List
        Tutorials: Create Cross-Context Resources, Cross-Context AJAX Login, Template-Based Actions, Remove Extensions from URLs

        Failure is just another word for saying you didn't want to try. "It can't be done" means "I don't know how".
        • 10208 ☆ A M B ☆
        • 1,780 Posts
        I just place the css file in the assets/templates/mytemplate directory, link in the head chunk as normal. My head chunk is static. Actually all the template chunks are static ($header, $body, $footer), and are editable outside of MODX. Changes to css files are instant, i.e. no cache clear needed. The static chunk files however, do require a cache clear to be seen.

        If you've got a chunk for the head that your template uses, just change the link to point to the assets folder the css lives in. Very simple.
          Frogabog- MODX Websites in Portland Oregon
          "Do yourself a favor and get a copy of "MODX - The Official Guide" by Bob Ray. Read it.
          Having server issues? These guys have MODX Hosting perfected - SkyToaster
          • 40088
          • 708 Posts
          Very thorough answer. For better or worse this gives me a lot more (even more than I had anticipated) to consider.

          Thank you.
            Todd
            • 40088
            • 708 Posts
            Yep, this is how I have it setup at the moment. Very simple indeed. As the above post indicates, there are many ways to handle this. Lots to think about.

            Thank you.
              Todd
              • 10208 ☆ A M B ☆
              • 1,780 Posts
              Ohhh, again misinterpreted. I thought you meant you'd left the CSS files somewhere else entirely (another server maybe).

              I'd love to see Fuzzycallogic's system in action. It sounds way cool, yet a little too complicated for me to even begin to understand. Static files make me happy, before 2.1 all we had was the includeFile snippet. I've stayed away from putting CSS into MODX because I really don't enjoy editing within MODX at all. I'm cheap, Notepad++ works great for my purposes.
                Frogabog- MODX Websites in Portland Oregon
                "Do yourself a favor and get a copy of "MODX - The Official Guide" by Bob Ray. Read it.
                Having server issues? These guys have MODX Hosting perfected - SkyToaster
                • 40088
                • 708 Posts
                Quote from: frogabog at Aug 12, 2012, 08:03 PM
                I'd love to see Fuzzycallogic's system in action. It sounds way cool

                It does sound cool. I would also like to see it in action.

                I don't like editing in any CMS, give me a dedicated programmers editor any day. The ability to tie static files into MODX is a very useful option (for me).
                  Todd
                  • 10208 ☆ A M B ☆
                  • 1,780 Posts
                  Maybe Fuzzy will make a video someday... hint, hint :~}
                    Frogabog- MODX Websites in Portland Oregon
                    "Do yourself a favor and get a copy of "MODX - The Official Guide" by Bob Ray. Read it.
                    Having server issues? These guys have MODX Hosting perfected - SkyToaster
                    • 39932
                    • 483 Posts
                    @Frogabog
                    Maybe Fuzzy will make a video someday...

                    If you click the link in my signature, you should be able to see the videos demoing the back-end management. The system is utilized in backend (manager) and then can be further distributed to the front-end. I can't do the rest of the videos until Extended Dialog opens up on the 24th. (I'm also still learning how to do a transport package). They aren't great and need to be remade (they were my first). They give the general idea, however. All of my JS, CSS, Plugins and Snippets are managed with it. I'd also like to take the time to make some nice import/export snippets.

                    @todd.b
                    I don't like editing in any CMS, give me a dedicated programmers editor any day...

                    This is the goal of RO.IDEs, and so far it works pretty well. RO.IDEs manages CSS, JS, Snippets, and Plugins. Right now, each editor (I have 4) is managed separately. I'm still trying to tie down the object hierarchy. JS is proving to be the major pain there, but it works... just not as well as I would like.

                    The ability to tie static files into MODX is a very useful option (for me)...

                    I personally can't stand uploading or downloading. LOL. The wait time just raises my ire. smiley
                      Website: Extended Dialog Development Blog: on Extended Dialog
                      Add-ons: AJAX Revolution, RO.IDEs Editor & Framework (in works) Utilities: Plugin Compatibility List
                      Tutorials: Create Cross-Context Resources, Cross-Context AJAX Login, Template-Based Actions, Remove Extensions from URLs

                      Failure is just another word for saying you didn't want to try. "It can't be done" means "I don't know how".
                      • 10208 ☆ A M B ☆
                      • 1,780 Posts
                      Quote from: fuzzicallogic at Aug 12, 2012, 09:07 PM


                      The ability to tie static files into MODX is a very useful option (for me)...

                      I personally can't stand uploading or downloading. LOL. The wait time just raises my ire. smiley


                      LOL, takes me that long to click to the other tab. ctrl+s comes out of my fingers with a quickness, what I can't stand is having to click a button to save anything. That includes MODX saves. Not everything works with ctrl+s in MODX either.

                      Looking forward to checking your videos out. I plan to be properly humbled...

                        Frogabog- MODX Websites in Portland Oregon
                        "Do yourself a favor and get a copy of "MODX - The Official Guide" by Bob Ray. Read it.
                        Having server issues? These guys have MODX Hosting perfected - SkyToaster