We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 12410
    • 353 Posts
    Hi Guys,
    I understand that weblinks only allow absolute urls. If I want to create a child document that links to a different already created document then whats the best method. I normally use a weblink but would prefer a method with a relative url.

    For sample purposes if i have the below in the navigation tree:

    animals>> id=1
    -cats id=2
    -dogs id=3
    -horses id=4

    Equestrian>> id=5
    -horses id=4

    I would like Equestrian>horses to go to animals>horses

    Thanks




      • 9207 ☆ A M B ☆
      • 2,475 Posts
      I had to come up with something similar to handle a master "Template" folder that I copied: each copy had to link to the *relative* page in its hierarchy, so the normal MODx link syntax didn’t work because it links to an absolute URL as you noted.

      The solution was a bit ugly, but it worked: it involved using the Ultimate Parent snippet and an output filter:

      <a href="[[~[[!UltimateParent? &topLevel=`3`]]]][[~207:stripString=`[[~113]]`]]">Relative Link</a>


      In the above example page 113 was the parent folder, and 207 was the target page in the hierarchy. This let me copy something like:

      www.mysite.com/some-folder/somepage

      And end up with links to

      www.mysite.com/copied-folder/somepage