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

    I’ve left this for some weeks, so maybe I’ve just forgotten something, but I seem to have problems I didn’t a few weeks ago with test pages.

    I’ve a few links to CSS files in my template, but only some pages seem able to retrieve the CSS files. This does seem largely connected with what folder level the page is at. The test home page, and the first level pages (one level down) seem to display properly, but not the lower pages.

    The link code I use:

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


    Using the manager, these pages don’t display at first, but do after a few goes, so it seems to be some kind of caching problem. However, they never display on the webpages, no matter what kind of refresh I try.

    The CSS files have "cacheable" and "empty cache" checked.

    Any ideas of what I’m doing wrong?

    P.S. Now that I look again, it is completely hit or miss if the pages show correctly inside the manager. - I’m completely perplexed.
      • 37272
      • 216 Posts
      OK,

      I don’t know what I did from a few weeks ago, I’ve corrected the path to the CSS files. - It’s all fine now.
        • 22303 MODX Staff
        • 10,725 Posts
        Typically, FYI, when using Friendly Alias Paths option, you need to use URLs relative from the web server root and not the root of the site, though these may be the same in most cases. Or, alternatively, you can use relative paths from the site root on all pages and just simply include a <base href="[(site_url)]" /> in the HEAD of your templates. This ensures that all relative links are consider relative to the specified base href location, regardless of what ’virtual’ folder your content is located in.
          • 37272
          • 216 Posts
          Hi,

          I simply changed the CSS links to:

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

          Did the trick. wink


          Edit: typo
            • 37272
            • 216 Posts
            Hmmm.

            The pages still don’t display consistantly in the manager. Why would that be?
              • 37272
              • 216 Posts
              HI Jason,

              I tried your suggestion, in case it helped, but it appears to make no difference. "base href" is not something I’m at all familiar with. I assume it’s just a case of slotting in [nobbc]<base href="http://www.example.com" />[/nobbc], but I’m not sure. Why would I use square brackets? - I did try it, but of course, it broke the pages.

              Thanks.
                • 28042 ☆ A M B ☆
                • 24,524 Posts
                The [(site_url)] is a MODx tag that inserts the site url as defined in the config.inc.php file; it is a "site variable", similar to [(site_name)] or [(site_start)]. It is used exactly as explained above.
                <base href="[(site_url)]" />
                  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
                  • 22303 MODX Staff
                  • 10,725 Posts
                  The default content and included template has an example usage of the base tag, but typically it will look like this in your template. The BASE tag simply sets the root path for all relative URL links in a rendered page. So if you add a ’/’ in front of your generated links, it would not be effective, as those then become absolute links to the root of the web server. The combination of the BASE tag plus using all relative paths in your template and content makes your site more portable from server environment to server environment.

                  And the [(site_url)] is just a MODx tag which is replaced with the proper value of the root of your site when a page is rendered.

                  <html>
                  <head>
                  <base href="[(site_url)]" />
                  ...
                  
                  </head>
                  <body>
                  ...
                  </body>
                  </html>
                  


                  Hope that helps clarifly. You can learn more technical information about the HTML element BASE at W3C’s web site.

                  [PS: Susan beat me to the post... but I’ll post anyway for reinforcement and additional information...]
                    • 37272
                    • 216 Posts
                    I’m sorry, this plain does not work. It takes an age for the page to load, and then it is devoid of all CSS.

                    I’ve tried all of these:

                    <base href="[(http://www.xxxxxx.org)]" /> (I assume this to be correct form)

                    and

                    <base href="[(www.xxxxxx.org)]" />

                    and

                    <base href="[(xxxxxx.org)]" />

                    I have placed these inside the head of the template. I use CSS links, thus:

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

                    Links to images are also killed. I don’t understand what’s wrong with my links.
                      • 37272
                      • 216 Posts
                      Hi, again,

                      Just to say that I did try removing the leading"/" with css files, but it made no difference. The css files are within their own folder in the manafer, but I assume that should make no difference, because this is managed by using "[~7~]" IDs. sad