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,

    When using the ID in menus, I end up with my home page appended with "/home", the alias. I thought I’d be able to use site_start, but no. If I use remove the alias, I end up the page ID instead. For future proofing, it would be better that my internal links to the home page refer to the domain name only. Of course, the "/home" will leak out of the site too, making things worse. I know, I could always add redirects if it ever came to that, but it is better to just avoid it. Of course I can just use the URL in my menus instead, but thought there must be a more elegant solution. undecided At the moment I am building my main menus by hand, but I expect that later I will really need snippets to produce links, so a real solution is needed. I also suspect that there also maybe ranking issues if I don’t use the plain domain name. I know I can use "index", but I’d rather not if I can avoid it.

    Anyone?

    Thanks.
      • 24414
      • 45 Posts
      Add the following code as a plugin:

      $output = $modx->documentOutput;
      $urlOriginal = 'href="1" ';
      $urlNew = 'href="/" ';
      $modx->documentOutput = str_replace($urlOriginal, $urlNew, $output);
      


      In the same area as the plugin go to the system events tab and select the checkbox
      ’OnWebPagePrerender’.

      With Friendly URLs turned on set the home page alias to "1", modx will now
      convert links to the home page to go to
      "/"

      Adjust the string you need to replace ($urlOriginal)as required by your setup.
        • 33337
        • 3,975 Posts
        Why dont you use [(site_url)] ?

        Hope this helps.

        regards,

        zi
          Zaigham R - MODX Professional | Skype | Email | Twitter

          Digging the interwebs for #MODX gems and bringing it to you. modx.link
          • 37272
          • 216 Posts
          Hi Zi,

          I’m sure I’d have given it a go if it was listed in Modx tags. I know, now that you mention it, I’ve seen the tag before, in the sample site, maybe. Well, I deleted that just after installing.

          Thanks Zi, and thanks Ram. If for some reason site_url does not forefill my needs, I’ll look at the snippet code.