• furls, alias', and linking to the home page#

  • colinx Reply #1, 5 years, 5 months ago

    Reply
    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. 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.


  • ram Reply #2, 5 years, 5 months ago

    Reply
    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.


  • Zaigham (aka zi) Reply #3, 5 years, 4 months ago

    Reply
    Why dont you use [(site_url)] ?

    Hope this helps.

    regards,

    zi


  • colinx Reply #4, 5 years, 4 months ago

    Reply
    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.