relative links in HTML editor in IE

relative links in HTML editor in IE

by Gustav W Delius -
Number of replies: 15
The code for the HTML editor has been modified by someone so that in IE all relative links are converted to absolute links relative to the form page. That is clearly undesirable. For example if one uploads a set of html pages that refer to each other with relative links then they work fine in Moodle but as soon as one edits one of them in the HTML editor the links break. Can anyone remember why the modification was made?
Average of ratings: -
In reply to Gustav W Delius

Re: relative links in HTML editor in IE

by Janne Mikkonen -
Backups!

Sorry that I haven't participate enough lately, but I'm quite sick at the moment (theres something wrong with my teeth and maxillary sinus <- what a word???. And I'm using quite strong pain killers).

This is something that needs to be sorted out before anyone can start to create bookmark feature on the editor. Relative links or absolute links.

Cheers,
Janne
In reply to Janne Mikkonen

Re: relative links in HTML editor in IE

by Gustav W Delius -

Hi Janne, that was an amazingly quick reply!

Sorry to hear that you are in pain. My best wishes.

Can you explain a bit more what you mean by Backups?

In reply to Gustav W Delius

Re: relative links in HTML editor in IE

by Martin Dougiamas -
Bildo de Core developers Bildo de Documentation writers Bildo de Moodle HQ Bildo de Particularly helpful Moodlers Bildo de Plugin developers Bildo de Testers
Backups need to have full URLs so that the backup code knows what to do with links ... relative links don't always translate.

Even more importantly is emails, and filtering ... in which stuff fail to work with relative paths.

    http://moodle.org/mod/forum/discuss.php?d=3557

Sorry to hear about the illness, Janne!  Get well soon!
In reply to Martin Dougiamas

Re: relative links in HTML editor in IE

by Petr Skoda -
Bildo de Core developers Bildo de Documentation writers Bildo de Peer reviewers Bildo de Plugin developers
We could force all browsers to convert relative links to absolute ones, with the exception of relative anchors of course.

The relative linking of uploaded html files accessed through file.php is very problematic. IMHO all links should be strictly absolute, backup/restore process handles all necessary relinking.

Could anybody please supply some examples where he/she thinks relative links could be really useful?

skodak
In reply to Petr Skoda

Re: relative links in HTML editor in IE

by Martin Dougiamas -
Bildo de Core developers Bildo de Documentation writers Bildo de Moodle HQ Bildo de Particularly helpful Moodlers Bildo de Plugin developers Bildo de Testers
None of this is relevant for uploaded files ... relative links should be working fine for all cases under file.php (as long as you have slasharguments turned on).  Relative links in uploaded files are very important to have.

Can you give an example otherwise?
In reply to Martin Dougiamas

Re: relative links in HTML editor in IE

by Petr Skoda -
Bildo de Core developers Bildo de Documentation writers Bildo de Peer reviewers Bildo de Plugin developers
Relative links do work, but editing of uploaded files in HTMLArea in IE does not work - all relative links are converted to absolute links without file.php and arguments sad

Example
page: http://mysite/file.php/2/something/other.html
HTMLArea in IE coverts relative link: href="hmm.html"
to: href="http://mysite/files/hmm.html"

http://mysite/files/index.php is the address of the page with HTMLArea used for editing.
In reply to Petr Skoda

Re: relative links in HTML editor in IE

by Petr Skoda -
Bildo de Core developers Bildo de Documentation writers Bildo de Peer reviewers Bildo de Plugin developers
This IE specific problem with relative links in uploaded files could be solved in function stripBaseURL from htmlarea.php. First check if baseURL starts with "$CFG->wwwroot/files/" - in that case remove baseURL from the string argument to create relative link.
In reply to Petr Skoda

Re: relative links in HTML editor in IE

by Ron Banks -
Right now I have a need in creating books that need more than one level of subchapters, which if I used subchapters anyway the TOC gets too long and cumbersome in the book as the sub chapters do not collapse (this would be a good feature in the book mode - collapsing subheadings - another issue, another time).  Therefore, I am trying to create subchapters and below using relative links within the html but it keeps breaking as it tries to make absolute links to itself.
In reply to Ron Banks

Re: relative links in HTML editor in IE

by Petr Skoda -
Bildo de Core developers Bildo de Documentation writers Bildo de Peer reviewers Bildo de Plugin developers
Recent fix in 1.4CVS should solve your problem with relative anchor links, it may eventually be merged back to 1.3.1+ branch.

If you need "longer" books, please consider creating several books instead of one. Loooong books are hard to read and hard to print. You can also manually create master TOC on the first page of each book. On the main course page books can be grouped (label followed by indented list of books).

I am planning the collapsible TOC after the introduction of templates in Moodle.

Decision not to implement more levels was pedagogical, it could be implemented within several hours. Maybe after TOC display is somehow improved, I will add one more level wink
In reply to Petr Skoda

Re: relative links in HTML editor in IE

by Ron Banks -

Thank you for working on this.  I will be looking forward to the 1.3.1+ and 1.4 coming out.  I will try it out on the 1.4CVS as well.  I appreciate your work as it benefits us all.

You talked of manually creating a master TOC on the first page, could you be more specific?  I am assuming your are speaking of creating links in the first page.

Your label approach is quite creative.  I had not thought about that.  I will try to implement that and see the results.

Ron Banks

In reply to Ron Banks

Re: relative links in HTML editor in IE

by Petr Skoda -
Bildo de Core developers Bildo de Documentation writers Bildo de Peer reviewers Bildo de Plugin developers
"Master TOC" was just an idea, you understand it correctly. Usually the first page of a book contains some book description, manually created links to some other books could help with the orientation.
In reply to Martin Dougiamas

Re: relative links in HTML editor in IE

by Gustav W Delius -

Ah yes, I forgot that this issue had been discussed before. So I understand the value of converting relative links to absolute links now. But surely a relative link should be converted to an absolute link with respect to the page itself, not the editor page.

We currently have the situation that when using the HTML editor on mozilla converts relative links to absolute links but on IE relative links are converted to absolute links with respect to the editor page.

If I understand correctly neither is what we want. Rather we want in all browsers all relative links to be converted to absolute links with respect to the actual page.

In reply to Gustav W Delius

Re: relative links in HTML editor in IE

by Petr Skoda -
Bildo de Core developers Bildo de Documentation writers Bildo de Peer reviewers Bildo de Plugin developers
Another solution could be to force users to enter only absolute paths or relative anchors. Simple popup would inform users that relative links are not allowed, they could be also given some info on how to write absolute links.

Other users (not using HTMLArea) should be given some general info on what links Moodle works with and how backup/restore works.
In reply to Petr Skoda

Need relative links instead of absolute ones

by Lancelot Dulac -
Hi all!

I´m new to this, so excuse me if my question has already been answered in this thread and I didn´t understand it.

I have a dynamic ip in my server, which means that whenever I´m starting it, all the absolute links (wee icons in the forums, pictures, etc) stop working.

I´d rather have relative links which would stay there regardless of the ip, linking to say "moodledata/sessions/2/file" instead of http://myip/Myfolder/...

Any suggestions about how to fix this problem? Thanks a lot
In reply to Petr Skoda

Need relative links instead of absolute ones

by Lancelot Dulac -
Hi all!

I´m new to this, so excuse me if my question has already been answered in this thread and I didn´t understand it.

I have a dynamic ip in my server, which means that whenever I´m starting it, all the absolute links (wee icons in the forums, pictures, etc) stop working.

I´d rather have relative links which would stay there regardless of the ip, linking to say "moodledata/sessions/2/file" instead of http://myip/Myfolder/...

Any suggestions about how to fix this problem? Thanks a lot