We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • Hmmm. I hadn’t thought of doing that. Sounds like an undiscovered feature. I’m sure someone will come up with a great way to use CSS templates someday.
      Time is what keeps everything from happening all at once.
      • 16859
      • 8 Posts
      I had the same problem myself. SiNNuT’s answer helped clear things up. Thanks! Didn’t even have to post to find the answer I was looking for. I think the Revo documentation should mention adding stylesheets this way.
      • @SiNNuT,
        Will this become a problem if you use Wayfinder/Ditto snippets?
          Rico
          Genius is one percent inspiration and ninety-nine percent perspiration. Thomas A. Edison
          MODx is great, but knowing how to use it well makes it perfect!

          www.virtudraft.com

          Security, security, security! | Indonesian MODx Forum | MODx Revo's cheatsheets | MODx Evo's cheatsheets

          Author of Easy 2 Gallery 1.4.x, PHPTidy, spieFeed, FileDownload R, Upload To Users CMP, Inherit Template TV, LexRating, ExerPlan, Lingua, virtuNewsletter, Grid Class Key, SmartTag, prevNext

          Maintainter/contributor of Babel

          Because it's hard to follow all topics on the forum, PING ME ON TWITTER @_goldsky if you need my help.
          • 27347
          • 65 Posts
          Just to be clear, i did the test to see if it works. I just use regular file-based css sheets. Revo gives you the freedom to put your files anywhere you like, be it in the assets directory or anywhere you choose.

          One advantage of resource based css could be users can easily edit the css.
          • Another would be conditional styles using a snippet, such as showing a nighttime background at night and a daytime background during the day. You could also use sessions or cookies to dynamically set styling. Any MODx tags will work; just keep in mind that any resource-specific variables such as [*id*] would apply to the CSS resource, not the actual page the user is viewing!
              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
              • 17886
              • 4 Posts
              Quote from: anso at Jul 21, 2010, 08:39 AM

              Hi,

              Don’t understand what is exactly your problem... I use css in resources (stored in db), and have no problem with that...

              I created a container with an empty template, called it css, with an alias "css" (I use FURL), in this container I created as many resource (content type CSS, empty template) as I need stylesheets, don’t forget to give it an alias.

              In each stylesheet I put some chunks (in the chunks I put the css code)...

              I call the stylesheet I want by using a snippet, but I can call one specifically by referencing its alias name like that
               <link rel="stylesheet" media="screen" type="text/css" href="css/mystylesheet.css" />
              

              It works fine ...
              Are you sure you are using an EMPTY template for your css resource ? The problem might be here...
              Hope this helps, if you need some example PM me...
              Cheers
              Could I ask you how exactly you got this working? I am having some trouble with it.

              Right now I have created a resource where
              on "Create/Edit Document"
              ID: 4
              Template: (empty)
              Published: checked
              Title: css
              Resource alias: css
              Hide from menu: checked


              on "Page Settings"
              Container: checked
              Searchable: unchecked
              Content type: CSS
              


              Then I made a resource with that container as parent resource where
              on "Create/Edit Document"
              ID: 3
              Template: (empty)
              Published: checked
              Title: mainStyle
              Resource alias: mainstyle
              Hide from menu: checked


              on "Page Settings"
              Container: unchecked
              Searchable: unchecked
              Content type: CSS
              


              I can reference the style sheet using mainstyle.css in my template, but it’s not possible to use css/mainstyle.css.
              Did I miss something?

                Madeye
                • 1778
                • 659 Posts
                Not sure if it’s the source of your problem, but in my case the resource "container" (in your case the resource ID 4 with alias "css") has a content-type HTML (the default one), only the resources containing the css code (in you case resource with ID 3 and alias mainstyle) has a content-type "css".

                I guess if your css container is content-type css, the path cannot understand the "css/" part...

                Hope this helps
                Cheers
                  • 17886
                  • 4 Posts
                  Thanks for the reply.

                  Unfortunately changing the type to html doesn’t change anything. huh

                    Madeye
                    • 1778
                    • 659 Posts
                    In your template(s) using the css do you have put somewhere (in the <head></head>) "<base href="[[++site_url]]" />" ?

                    Can you reach a resource in a container with an URL like: http//yoursite.com/onecontainer/oneresource.html ?

                    If not, maybe the FURL are not well set in your system settings...
                    Cheers
                      • 17886
                      • 4 Posts
                      It seems there is something wrong with my htaccess file. But I am unsure what is causing this problem.
                      I have used the standard file that was in the modx folder.

                      # MODx supports Friendly URLs via this .htaccess file. You must serve web
                      # pages via Apache with mod_rewrite to use this functionality, and you must
                      # change the file name from ht.access to .htaccess.
                      #
                      # Make sure RewriteBase points to the directory where you installed MODx.
                      # E.g., "/modx" if your installation is in a "modx" subdirectory.
                      #
                      # You may choose to make your URLs non-case-sensitive by adding a NC directive
                      # to your rule: RewriteRule ^(.*)$ index.php?q=$1 [L,QSA,NC]
                      
                      RewriteEngine On
                      RewriteBase /modx
                      
                      
                      
                      # Rewrite www.domain.com -> domain.com -- used with SEO Strict URLs plugin
                      #RewriteCond %{HTTP_HOST} .
                      #RewriteCond %{HTTP_HOST} !^example-domain-please-change\.com [NC]
                      #RewriteRule (.*) http://example-domain-please-change.com/$1 [R=301,L]
                      #
                      # or for the opposite domain.com -> www.domain.com use the following
                      # DO NOT USE BOTH
                      #
                      #RewriteCond %{HTTP_HOST} .
                      #RewriteCond %{HTTP_HOST} !^www\.example-domain-please-change\.com [NC]
                      #RewriteRule (.*) http://www.example-domain-please-change.com/$1 [R=301,L]
                      
                      
                      
                      # Rewrite secure requests properly to prevent SSL cert warnings, e.g. prevent 
                      # https://www.domain.com when your cert only allows https://secure.domain.com
                      #RewriteCond %{SERVER_PORT} !^443
                      #RewriteRule (.*) https://example-domain-please-change.com.com/$1 [R=301,L]
                      
                      
                      
                      # The Friendly URLs part
                      RewriteCond %{REQUEST_FILENAME} !-f
                      RewriteCond %{REQUEST_FILENAME} !-d
                      RewriteRule ^(.*)$ /modx/index.php?q=$1 [L,QSA,NC]
                      
                      
                      
                      # Make sure .htc files are served with the proper MIME type, which is critical # for XP SP2. Un-comment if your host allows htaccess MIME type overrides.
                      
                      #AddType text/x-component .htc
                      
                      
                      
                      # If your server is not already configured as such, the following directive
                      # should be uncommented in order to set PHP's register_globals option to OFF.
                      # This closes a major security hole that is abused by most XSS (cross-site
                      # scripting) attacks. For more information: http://php.net/register_globals
                      #
                      # To verify that this option has been set to OFF, open the Manager and choose
                      # Reports -> System Info and then click the phpinfo() link. Do a Find on Page
                      # for "register_globals". The Local Value should be OFF. If the Master Value
                      # is OFF then you do not need this directive here.
                      #
                      # IF REGISTER_GLOBALS DIRECTIVE CAUSES 500 INTERNAL SERVER ERRORS :
                      #
                      # Your server does not allow PHP directives to be set via .htaccess. In that
                      # case you must make this change in your php.ini file instead. If you are
                      # using a commercial web host, contact the administrators for assistance in
                      # doing this. Not all servers allow local php.ini files, and they should
                      # include all PHP configurations (not just this one), or you will effectively
                      # reset everything to PHP defaults. Consult www.php.net for more detailed
                      # information about setting PHP directives.
                      
                      #php_flag register_globals Off
                      
                      
                      
                      # For servers that support output compression, you should pick up a bit of
                      # speed by un-commenting the following lines.
                      
                      #php_flag zlib.output_compression On
                      #php_value zlib.output_compression_level 5
                      
                      
                      
                      # The following directives stop screen flicker in IE on CSS rollovers. If
                      # needed, un-comment the following rules. When they're in place, you may have
                      # to do a force-refresh in order to see changes in your designs.
                      
                      #ExpiresActive On
                      #ExpiresByType image/gif A2592000
                      #ExpiresByType image/jpeg A2592000
                      #ExpiresByType image/png A2592000
                      #BrowserMatch "MSIE" brokenvary=1
                      #BrowserMatch "Mozilla/4.[0-9]{2}" brokenvary=1
                      #BrowserMatch "Opera" !brokenvary
                      #SetEnvIf brokenvary 1 force-no-vary


                      Could anyone give me a hint here?

                      EDIT: I found the solution (I think). At least it’s working now smiley
                      What I did to solve this was change the system settings in modx. I just changed the option "Use Friendly Alias Path" (use_alias_path) to YES, and then it works.
                        Madeye