Community & Support

tinymce and path filter module

I am creating the internal links on my first drupal website but I have a problem. Installation went smooth, documentation is great, and till now I found a module for every need I had. I am using the following modules: Global Redirect, Meta tags, Pathauto, Path Filter and TinyMCE.

I am using path filter to avoid a broken link when I rename a title of a page.

The problem is that TinyMCE inserts a leading slash "/" before the "internal:" from path filter so the link does not work.

So instead of this <a href=”internal:/node/303">my internal link</a>
I get this: <a href="/internal:/node/303">my internal link</a>

I already tried some things but without success.

First I set "Apply source formatting: " to "false" in the TinyMCE module settings.

Next I found in the readme.txt of path filter this info:

-----------------------
  USE WITH TINYMCE [3]
-----------------------
In its default configuration, TinyMCE will treat a link to "internal:foo"
as a normal relative URL and try to prefix it with the appropriate base URL,
messing it up in the process. This can be prevented by including the following
at the end of a custom TinyMCE theme function as described in TinyMCE's
INSTALL.txt.

  if (isset($init)) {
    $init['convert_urls'] = 'false';
  }

If you are not already using a custom theme for TinyMCE, adding the following
function to your template.php file should be sufficient.

function phptemplate_tinymce_theme($init, $textarea_name, $theme_name, $is_running) {
  $init = theme_tinymce_theme($init, $textarea_name, $theme_name, $is_running);
 
  // Disable conversion of relative URLs so we can use pathfilter.module
  // and it's "internal:node/99" style paths.
  if (isset($init)) {
    $init['convert_urls'] = 'false';
  }

  return $init;
}
--------------------------------------

I tried to add the code to my theme’s template.php but it does not solve the problem.

By the way I have no idea what they mean by the custom TinyMCE function.

Any help would be greatly appreciated.

Comments

Found a solution

I found a solution in this post. (there is a lot of info there so here is the summary)

Open the "tinymce.module" file (in the TinyMCE module directory) and find the line starting with "$init['document_base_url']" and add a new line underneath, so it now reads:

<?php
  $init
['document_base_url'] = "$host"
 
$init['convert_urls']  = "false";
?>

That's it !!

No more TinyMCE

I had another problem with TinyMCE: embedding a youtube video: does not work with copy-paste from the youtube code in the editor, again TinyMCE alters the code.

Also I experienced problems with TinyMCE and Firefox 3, so I had to use IE7 to edit pages :-/

That's it, no more TinyMCE, it causes more problems than it solves, at least in my case.

I am now using the BUEditor module, it does what I tell it to do, which is good.

Does this solution still work?

I have the latest 6.9 drupal, 6.x-1.1-dev TinyMCE and 6.x-1.0 Path filter yet this is still not working for me. The URLs are being re-written properly:

<img alt="chelsea and WS fac/students" src="internal:sites/default/files/Chelsea.jpg" mce_src="internal:sites/default/files/Chelsea.jpg" style="width: 423px; height: 228px;" width="500" height="271">

However I still get broken image boxes.

Wysiwig module

Try the Wywiwig API module with TinyMCE 3, instead of the TinyMCE.module. The Wysiwig module still has the problem where TinyMCE link rewrites the URL. The patch described here disabled the TinyMCE convert_url's feature:
http://drupal.org/node/369115

This worked for me with Wysiwig 1.0, Drupal 6, TinyMCE 3.1.

I also had problems with Path Filter, and found Pathologic was better. With Pathologic.module you can use the 'internal:' prefix, or not, and it re-writes very nicely.

You are better off getting CodeProtect

Get CodeProtect addon for tinymce and turn off all of your filters. that's all you really need to do and tiny will play nice.

nobody click here