We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 32071
    • 26 Posts
    I am trying to replicate my standard css workflow into modx to utilize the power of modx.

    My situation is that I can access the resource with the use-friendly-urls no:
    chunk:
    <link rel="stylesheet" href="[[~4]]" type="text/css" >
    html output:
    <link rel="stylesheet" href="index.php?id=4" type="text/css" >
    This works.

    When I turn use-friendly-urls yes
    chunk:
    <link rel="stylesheet" href="[[~4]]" type="text/css" >
    html output:
    <link rel="stylesheet" href="container/my-style.css" type="text/css" >
    This is what I prefer.
    It does not work.

    How do I get the output of use-friendly-urls yes to work?
    I prefer <link rel="stylesheet" href="container/my-style.css" type="text/css" >

    unfortunately this is looking for valid css files in a valid css directory.

    Any help or input is appreciated.

    Regards,
    William
      • 21872
      • 95 Posts
      Is "content type" set to CSS in your page settings for resource 4?
        • 32071
        • 26 Posts
        yes.

        I am starting to think that index.php?id=4 is something I will need to live with.
        Would be sexier though if it was index.php?alias

        Regards,
        William
          • 3749
          • 24,544 Posts
          Make sure you have this in the <head> section of your template:

          <base href="[[!++site_url]]" />

            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 32071
            • 26 Posts
            yep.
            did not have the ! though.

            Tried it. No luck.

            Just to make sure on the .htaccess file:

            RewriteEngine On
            RewriteBase /
            
            # The Friendly URLs part
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]


            Are these the only lines that need to be uncommented?

            Thanks,
            William
              • 3749
              • 24,544 Posts
              Yes.

              Make sure the rewrite engine is on. It’s off by default in XAMPP, for example.
              Be sure it’s .htaccess and not ht.access.
              Make sure that you have the Use Friendly URLs System Setting set to yes.
                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting
                • 32071
                • 26 Posts
                Thanks. did all that.

                Problem comes when I have Use Friendly URLs System Setting set to yes.

                The browser interprets the href as if it is a directory and file. It is not looking for the resource document.

                Regards,
                William
                  • 21872
                  • 95 Posts
                  OK, forgive me if this is too obvious but to use friendly urls and set up a fake directory structure, you need to either supply the fake path as part of the alias or set "Use Friendly Alias Path" to yes. Also, make sure you’ve published the resource you are using as CSS.

                  For the CSS resource, if you use a template that contains nothing but the [[*content]] tag and your settings are as described, you should be able to view the css. If you can, check the response header in the net tab of firebug or the resources tab in chrome/safari web inspector. If it says content-type text/css, you should be able to use the technique you describe.

                  If you can see your raw css where you expect it and the browser reports that it is being delivered as css, then use that url in your link tag... I don’t see any advantage to using the resource id versus the resource alias, especially since you might later delete that particular resource. You could then re-use the alias on another resource or use a static file on your server at the same location without editing the template.
                    • 32071
                    • 26 Posts
                    Thanks everyone.
                    I did not solve the issue but it is resolved.

                    I created a new domain (nice to have a whm and few extra domain names to play with)

                    Did a fresh install of modx revolution in the root directory, tabbed back and forth between old manager and new to replicate.

                    bam. It works.
                    very nice.

                    I do not know what the cause of the problem was. I did eliminate the .htacess file. Could have been a hiccup.

                    Happy New Year!

                    William