Page 1 of 1

Relative links in TinyMCE problem

Posted: Wed Sep 26, 2007 7:47 pm
by djprozac
Hey guys,

I've searched the forums for this problem and there are quite a lot of topics about it, but none seem to have a solution...

Whenever I try to insert an internal link to a page (e.g., #Test), the generated HTML comes out ok (I think):

Code: Select all

<a href="#Test">Go to test</a>
Firefox and Internet Explorer interpret these links as links to: http://www.domain.com/#Test

Is there a way to make TinyMCE make links to http://www.domain.com/page_the_anchor_resides_on/#Test?

Re: Relative links in TinyMCE problem

Posted: Sat Sep 29, 2007 9:03 am
by kermit
i remember running into a similar problem with internal page links at least a year ago, and started using {anchor} for them. to link to one on a *different* page, see {cms_selflink}. usage is something like this:

{anchor anchor='bottommenu' text='internal link'}

{cms_selflink anchorlink='bottommenu' page='contact-us' dir='anchor' text='internal link on different page'}

Re: Relative links in TinyMCE problem

Posted: Fri Jul 01, 2011 6:48 am
by oct4th
I fiddled with this for a while and came upon a solution that works for me.

1) Change your template metadata tag to: {metadata showbase="false"}

2) Uncheck "Generate relative urls" in the TinyMCE advanced tab.

3) Follow the instructions here:
Starting at line 65 [of modules/TinyMCE/templates/tinyconfig.tpl], you'll see:

{if $relativeurls=="true"}
relative_urls : true,
remove_script_host : true,
{else}
relative_urls : false,
remove_script_host : false,
{/if}

Change the second occurrence of remove_script_host from false (bold above) to true, so that the script host is always removed.
4) The above 3 steps fix the anchor issues, but now when using cms_selflink in TinyMCE the links come out like: http://www.site.com/www.site.com/page/link due to the absolute href created by Tiny and the full path created by cms_selflink.

I decided the easiest way was to kill the cms_selflink creation by Tiny. I edited modules/TinyMCE/TinyMCE.module.php and changed line 451 from:

tinyMCE.activeEditor.execCommand('mceInsertContent', false, '<a href=\"{cms_selflink href=\'" . $entry->Alias() . "\' ".$additions."}\">'+sel+'</a>');";

to:

tinyMCE.activeEditor.execCommand('mceInsertContent', false, '<a href=".$entry->GetURL().">'+sel+'</a>');";

This BYPASSES cms_selflink completely and creates a standard href URL. This is OK by me, but maybe not for some. Now both creating anchors and using the cms_selflink dropdowns in Tiny work as they should.

Thoughts? Hope this helps someone!