Author Topic: How do I make root relative links?  (Read 661 times)

Ecnassianer

  • Sr. Member
  • ****
  • Posts: 126
    • Carpe Chaos
How do I make root relative links?
« on: June 25, 2010, 06:02:22 am »
I'm putting a url attribute on an area in megazine and I want to link to a root-relative location. Read about root relative links here.

I want a link to:

To do this, I try this:

<area url="/Folder_In_Web_root">

What it produces is a link to this:

http://CarpeChaos.com/megazine//Folder_In_Web_root/

When it should be producing this:

http://CarpeChaos.com/Folder_In_Web_root/

Right now I'm working around with a relative link like this:

<area url="../Folder_In_Web_root/">

Which produces what I want, however this is messy.

Particularly, in my real use case (and not the simple example I just used), It looks like this:

../../../../../sites/default/files/Turi-ArenaAWU-1080.jpg

Ugh. How many dots is that?

Is there a way to do this currently? If not, consider this a feature request. :)
See my megazine at CarpeChaos.com

Hans Nücke

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 800
  • MegaZine3 Sales Manager
Re: How do I make root relative links?
« Reply #1 on: June 25, 2010, 08:45:14 am »
Stupid queston, but have you tried:
Code: (XML)
  1. <area url="Folder_In_Web_root">

i.e. just omitting the first slash?

Florian Nücke

  • κρύα πόδια
  • Administrator
  • Hero Member
  • *****
  • Posts: 1989
  • MegaZine3 Developer
    • MegaZine3
Re: How do I make root relative links?
« Reply #2 on: June 25, 2010, 04:02:55 pm »
Disregard Hans' post ;)

When it should be producing this:

http://CarpeChaos.com/Folder_In_Web_root/

You're right, of course. I forgot handling that case when I implemented the function adjusting the paths. Which was, like, 2 years ago or something... funny it never came up before.
It'll be easy to adjust it to properly handle absolute URLs, but I'm afraid it could break some old books, that use such URLs incorrectly.

Could a temporary workaround for you be to just add the domain in front of the links? I.e. use the full URL directly?

Hmm. I think I just might adjust it and add a book attribute that can be used to switch to the 'old' (= current) mode, so people whose books would break just have to adjust that, and not all of their paths... Screw it, doing a search and replace for ="/ to =" should work just fine and isn't that much more work. I'll add it directly.
« Last Edit: June 27, 2010, 01:04:29 pm by Florian Nücke »
For the Snark was a Boojum, you see.

Before you ask a question
          After you get an answer
  • please document your problem with the answer in the Project Wiki. (e.g. in the FAQs)
  • help others out if you can, by answering their questions on the forum.