We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36416
    • 589 Posts
    Quote from: DangerMouse1981 at Nov 17, 2010, 05:30 PM

    Forgive my naivety but I’m a little unclear as to the benefit Base Href provides over simply using URLs from the root of the domain. i.e. "/css/styles.css" rather than "css/styles.css"?
    I understand that the latter in that example would create problems on 404 pages, but it would work without issue with the prepended "/". From what I can see prepending links with "/" maintains portability and allows for the use of anchors (without hacks).

    I usually start developing my site prototypes in a subfolder, so that "/" wouldn’t work from the beginning, or later when moving to production (root).
    I love base tag... wink
      • 22629
      • 194 Posts
      Quote from: OpenGeek at Nov 20, 2010, 04:04 AM

      Certainly not if you develop or deploy in a subdirectory. Absolute paths ruin portability.

      Sure for static websites (or statically created links) but in a CMS that’s no longer an issue as the links are generated, right? So you can just change the config to say "you’re no longer at http://www.mydevsite.com/site but at http://www.mylivesite.com" and the next time MODx generates a link, it uses the new site URL.

      I’ve actually done this - I started developing my site at http://devserver/site and later moved it to http://newdevsite and all it required was to clear the MODx cache (and change a URL I had hard-coded.)

      Granted in CSS and Javascript this is still an issue, but that’s why my CSS and JS are static resources and use [[~...]] tags in them smiley
        Andy Shellam | www.networkmail.eu | @Pandy06269 @NetworkMail

        modx Revolution 2.2.6
        Windows 2012 | IIS 8 | php 5.4.11 | MySQL 5.5.29

        Content-Managed Websites Built on MODX
      • Quote from: Pandy06269 at Nov 26, 2010, 10:13 AM

        Granted in CSS and Javascript this is still an issue, but that’s why my CSS and JS are static resources and use [[~...]] tags in them smiley
        I’ve started using a property on my Templates for referencing things like CSS and JS files, template_url, giving it a value like:
        [[++assets_url]]templates/mytemplatename/

        then in my template I might use:
            <link href="[[+template_url]]css/960.css" rel="stylesheet" type="text/css" />
            <link href="[[+template_url]]style.css" rel="stylesheet" type="text/css" />
        
            <!--[if lt IE 9]>
            	<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js" type="text/javascript"></script>
            <![endif]-->
        
            <!--[if lte IE 7]>
            	<link href="[[+template_url]]css/ie.css" rel="stylesheet" type="text/css" />
            <![endif]-->
        


        I prefer this approach simply because using Static Resources for JS and CSS can incur more overhead than allowing browsers to properly cache them. In addition, I can easily switch the location of those files by altering the property value, say, if I wanted to redeploy the JS and CSS to a CDN.
          • 22629
          • 194 Posts
          Quote from: OpenGeek at Nov 26, 2010, 08:12 PM

          I prefer this approach simply because using Static Resources for JS and CSS can incur more overhead than allowing browsers to properly cache them. In addition, I can easily switch the location of those files by altering the property value, say, if I wanted to redeploy the JS and CSS to a CDN.

          Yeah but I mean my CSS and JS use modx tags inside them. E.g. in assets/css/style.css:

          body
          {
              background-image: url('[[~24? &scheme=`full`]]');
          }
          


          Resource #24 is a static resource pointing to an image for the site background, for example.

          I don’t ever have to worry about file paths or file renames breaking the site - as long as the IDs remain the same. If I didn’t have that stylesheet as a static resource, I wouldn’t be able to do this.

          Quote from: OpenGeek at Nov 26, 2010, 08:12 PM

          using Static Resources for JS and CSS can incur more overhead than allowing browsers to properly cache them

          Just out of interest, how does a static resource serving up a CSS file differ from serving up the CSS file directly. As long as the resource is set as cacheable in modx, and I don’t play with the caching headers in the output, surely the browser will treat the output as any other CSS file - it doesn’t know that it’s dynamically created in modx and not to cache it unless I tell it so (i.e. HTTP headers?)
            Andy Shellam | www.networkmail.eu | @Pandy06269 @NetworkMail

            modx Revolution 2.2.6
            Windows 2012 | IIS 8 | php 5.4.11 | MySQL 5.5.29

            Content-Managed Websites Built on MODX
          • Quote from: Pandy06269 at Dec 02, 2010, 10:59 AM

            I don’t ever have to worry about file paths or file renames breaking the site - as long as the IDs remain the same. If I didn’t have that stylesheet as a static resource, I wouldn’t be able to do this.
            Neither do I; I use the base href. tongue

            Quote from: Pandy06269 at Dec 02, 2010, 10:59 AM

            Quote from: OpenGeek at Nov 26, 2010, 08:12 PM

            using Static Resources for JS and CSS can incur more overhead than allowing browsers to properly cache them

            Just out of interest, how does a static resource serving up a CSS file differ from serving up the CSS file directly. As long as the resource is set as cacheable in modx, and I don’t play with the caching headers in the output, surely the browser will treat the output as any other CSS file - it doesn’t know that it’s dynamically created in modx and not to cache it unless I tell it so (i.e. HTTP headers?)
            You invoke PHP. That is automatically more overhead than serving any static file with the web server directly, and always will be. And there is no way for the web server to report if the CSS file has changed, so yes, it gets invoked on every request. Static files would actually be cached on the client.
              • 12512
              • 42 Posts
              Why don’t give users a choice?

              Some have legitimate reasons not use the base tag and have everything absolute incl. images and CSS. The anchor issue is one and I often use external content which I import or include which is another. MODx is so flexible in other areas and does not dictate anything. Why not apply the same freedom to the use or not use of the base tag?
                • 12512
                • 42 Posts
                Well, I have to say the MODx team is certainly listening. I just came across a new setting in Revo 2.1.0 called link_tag_scheme which does exactly what was discussed in this post: setting the default URL scheme.

                Change to abs and we have absolute URLs.

                You guys rock! lipsrsealed
                  • 37380
                  • 20 Posts
                  link_tag_scheme doesn't work for me.

                  Environment settings:
                  Revo 2.2.1
                  PHP 5.3.2
                  Apache 2.0

                  Set link_tag_scheme to "abs"
                  Set base_url (either/both context & system settings) to "/"
                  Cleared cache

                  Output when using [[~id]] is "foo/index.html"

                  Any thoughts? Thanks in advance smiley
                    • 3749
                    • 24,544 Posts
                    Is that from a link to your site_start page? If so, try it on another page.

                    You might also need to upgrade to MODX 2.2.4 (or to an even newer version on GitHub). Since it's a new setting, it may use code that's not in your version.



                    ------------------------------------------------------------------------------------------
                    PLEASE, PLEASE specify the version of MODX you are using.
                    MODX info for everyone: http://bobsguides.com/modx.html
                      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
                      • 37380
                      • 20 Posts
                      It happens everywhere. Homepage and deeper pages.

                      I'll upgrade ModX & keep this conversation updated then.

                      Thanks Bob for you reply. Love your book & site. Great work smiley