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

    I created a document with file type css which is named style and has ID 2. Now I want to reference it in my html template file. How can I do that? I can’t find the tag for a document in the documentation...

    Thanks
    Chris
      • 33337
      • 3,975 Posts
        Zaigham R - MODX Professional | Skype | Email | Twitter

        Digging the interwebs for #MODX gems and bringing it to you. modx.link
        • 5246
        • 12 Posts
        Thank you zi,

        I finally did that, but that did not solve my problem... Now, all it does is referencing the name of the file like from

        <link rel="stylesheet" type="text/css" href="[[~2]]">

        to

        <link rel="stylesheet" type="text/css" href="style.css">

        Of course this could not work because there is no CSS-file stored in the file-system. I created a document in the document tree and this is stored in the DB I think.


        • Quote from: Chris_Bones at Jul 16, 2010, 03:04 PM


          Of course this could not work because there is no CSS-file stored in the file-system. I created a document in the document tree and this is stored in the DB I think.


          If this isn’t working on your end, let us know what’s happening. I still have my CSS in files, but I’ve tested placing them in the database as resources and everything worked fine.
            Time is what keeps everything from happening all at once.
            • 5246
            • 12 Posts
            The point is: My approach seems to be generally wrong. I thought I could enter my styles into a document and then reference it in my template. But that does not work. So, my question is: Can I put my CSS-file into the database? And how do I reference it then?
            It would be fine if someone could simply explain that to me!
              • 4172
              • 5,888 Posts
              you can try jasons getValue to get the content of your resource or use chunks for your css.

              getValue:http://modxcms.com/forums/index.php/topic,48095.msg281956.html#msg281956
                -------------------------------

                you can buy me a beer, if you like MIGX

                http://webcmsolutions.de/migx.html

                Thanks!
                • 5246
                • 12 Posts
                Thanks Bruno17. This sounds like a let’s say non-standard-solution. But I thought putting CSS into a document is common because CSS is a standard doctype in MODx which can be chosen. So what is this option for? What do you do with those CSS-files in your document tree?
                  • 1778
                  • 659 Posts
                  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
                    • 27347
                    • 65 Posts
                    Just did a quick test on a fresh install of Revo RC3. I had no problem with resource/document based css. It works fine, with and without furls enabled.

                    Test settings:

                    Document: style
                    ID: 2
                    Uses Template: (empty)
                    Published: yes
                    Title: style
                    Resource Alias: style
                    Content Type: CSS
                    Content Disposition: Inline
                    Resource content: h1 { font-size: 160px; }

                    I can easily reference the document in a template like so: <link rel="stylesheet" type="text/css" href="[[~2]]">

                    It renders like:
                    <html>
                    <head>
                    <title>MODx Revolution - Home</title>
                    <base href="............." />
                    <link rel="stylesheet" type="text/css" href="index.php?id=2">
                    </head>
                    <body>
                    <h1>Hallo!</h1>
                    </body>
                    </html>

                    Following the link it shows the contents of resource id=2
                    With furls enabled you can approach with <domainname>/style.css
                      • 5246
                      • 12 Posts
                      Thanks for your answers!

                      @SiNNut Jackpot! Your explanation is great wink My mistake was to link my CSS file to my template. Everything works fine when I leave this field empty.