Relative links in TinyMCE problem

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Locked
djprozac

Relative links in TinyMCE problem

Post 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?
User avatar
kermit
Power Poster
Power Poster
Posts: 693
Joined: Thu Jan 26, 2006 11:46 am

Re: Relative links in TinyMCE problem

Post 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'}
eternity (n); 1. infinite time, 2. a seemingly long or endless time, 3. the length of time it takes a frozen pizza to cook when you're starving.
4,930,000,000 (n); 1. a very large number, 2. the approximate world population in 1986 when Microsoft Corp issued its IPO. 3. Microsoft's net profit (USD) for the quarter (3 months) ending 31 March 2007.
CMSMS migration and setup services | Hosting with CMSMS installed and ready to go | PM me for Info
User avatar
oct4th
Forum Members
Forum Members
Posts: 28
Joined: Wed May 21, 2008 6:33 pm
Location: US of A

Re: Relative links in TinyMCE problem

Post 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!
Locked

Return to “Modules/Add-Ons”