We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 32025
    • 305 Posts
    I am not sure how to articulate what I am trying to accomplish so please bare with me.

    I want to add links within my site. I have friendly URL’s enabled. Instead of adding a link like this: /information.html to many pages of my website I am looking for the variables that parse these links so I won’t have to update them later (this will save me at least a weeks worth of work). Since my folders will be deep, I need to add the variable instead of the whole domain.

    So instead of me manually adding a link like this: http://wwww.mysite.com/information.html or like this: /information.html I want to add the variable that will first bring up the domain name: [domain name path][link page]. This variable should parse the link like this: http://www.mysite.com/information.html

    So that when I paste these many variables in my content area I won’t have to change them later.

    I believe this is php so I don’t even know if parse is correct.
      Making the web a better place on site at a time! Dayton Web Design: http://www.dayton-web-design.com/
      • 3749
      • 24,544 Posts
      I might be misunderstanding your question, but the IDs of the documents (the numbers in parentheses after the names in the tree at the left) won’t ever change. If you you use MODx link tags for your links, MODx will make the URL for you. In Tools | Configuration, you can turn on "Use Friendly Alias" (to use the alias for the document in the URL) and "Use Friendly alias path" (if you want the full path).

      If your information document has an ID of 12, for example, instead of

      <a href="http://wwww.mysite.com/information.html">


      use this:

      <a href="[~12~]">



        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
        • 32025
        • 305 Posts
        BobRay thank you that was what I was looking for. I did have the alias and friendly urls activated.

        I am having one problem:
        This code:
        <a href="[~13~]">


        is producing this URL: http://www.mysite.com/information/information/board.html so it’s duplicating the information folder. I don’t see any settings that would duplicate this folder.

        You can see it on this page: http://70.85.226.130/~apicsday/information/recognition.html under: Officers, Directors, and Advisors link in the middle content area.

        Any ideas?
          Making the web a better place on site at a time! Dayton Web Design: http://www.dayton-web-design.com/
          • 3749
          • 24,544 Posts
          The only things I can think of that would make that happen are if there is a location folder (or a document with that alias) under the location folder in your document tree in the Manager or if you have an incorrect alias for that document or its parent.

          Nice site, BTW. smiley
            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
            • 32025
            • 305 Posts
            There is a document called: Information with an Alias of: information. It is a parent to several other pages:
            About Our Chapter
            Our Board
            Membership
            Members Only
            Recognition
            Contact Us
            News Letters

            It is also a container because of this. There are no other aliases or documents with this name in the child categories. The alias is correctly spelled.

            I checked the settings in Friendly URLs and nothing worked. I also checked the .htaccess code and that was what was sent with the installation (it works other than the parent category displaying twice)
              Making the web a better place on site at a time! Dayton Web Design: http://www.dayton-web-design.com/
              • 20413
              • 2,877 Posts
              So you are building your pages with physical files,
              instead of using MODx documents stored in the database...
                @hawproductions | http://mrhaw.com/

                Infograph: MODX Advanced Install in 7 steps:
                http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

                Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
                http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
                • 32025
                • 305 Posts
                mrhaw,

                Jackson P above is not the same as me (Please note: His reply looks like I may have written it). My links are in the database and made in the control panel. I think Jackson P maybe wrote in the wrong post?

                If not Jackson, the php coding above is not any more difficult to implement than a standard link (which I know how to implement). I am trying to get away from having to enter my site: http://www.mysite.com in any coding (that defeats the purpose of my question) smiley
                  Making the web a better place on site at a time! Dayton Web Design: http://www.dayton-web-design.com/
                  • 20413
                  • 2,877 Posts
                  Try...

                  adding a base href tag inside <head>
                  <base href="[(site_url)]"></base>


                  Alternative a base url tag in every link
                  <a href="[(base_url)][~1~]">home</a>
                    @hawproductions | http://mrhaw.com/

                    Infograph: MODX Advanced Install in 7 steps:
                    http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

                    Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
                    http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
                    • 32025
                    • 305 Posts
                    Bingo!

                    This code:
                    ><a href="[(base_url)][~13~]">Officers, Directors, and Advisors</a>

                    Works like a charm! Thank you mrhaw you saved me a ton of time on this project!! grin
                      Making the web a better place on site at a time! Dayton Web Design: http://www.dayton-web-design.com/
                      • 16783
                      • 1 Posts
                      Ummm....I have started using a totally different JS for generating Dynamic Links.

                      Dunn if you lot is going to like it? smiley

                      <!-- ONE STEP TO INSTALL DYNAMIC LINKS:

                      1. Copy the coding into the BODY of your HTML document -->

                      <!-- STEP ONE: Paste this code into the BODY of your HTML document -->

                      <center>
                      <form name="addresses">
                      do you want to ... <select name="list" onChange="update()">
                      <option value="mailto:[email protected]">email [email protected]
                      <option value="mailto:[email protected]">email [email protected]
                      <option value="http://www.netscape.com">go to www.netscape.com
                      </select>
                      <a href="updatelink">do it!</a>
                      </form>
                      </center>

                      <script language="javascript">

                      <!-- this script and many more are available free online at -->
                      <!-- the javascript source!! http://javascript.internet.com -->

                      <!-- begin
                      pos = 9999;
                      for(num=0;num<document.links.length;num++) {
                      if (document.links[num].href.indexOf("updatelink") != -1) {
                      pos = num;
                      num = 5000;
                      }
                      }
                      function update() {
                      if (pos!=9999) {
                      sel = document.addresses.list.selectedIndex;
                      document.links[pos].href = document.addresses.list[sel].value;
                      }
                      }
                      update();
                      // end -->
                      </script>

                      <p><center>
                      <font face="arial, helvetica" size="-2">Free JavaScripts provided

                      by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
                      </center><p>

                        Google Friendly Link Building Services For Advanced Webmasters. We offer only quality link building services for your website.