Reputation: 203
I added tinyMce editor in my textarea input form. Unfortunately I have troubles sending hyperlink absolute urls.
I create dynamically the pages within a php CMS.
I can start tinyMce and I can send formatted text. When I try to add url, the final result is not the absoluted url I added, but it is preceded by another string url, as showed under:
//Input url: www.example.it, will process the following result:
//http://www.myDomain.example/folder/\"http://www.example.it\"
Because of that the final link doesn't work, even if in the tinyMce preview all seems to be good.
I followed the indications written in the official website FAQ to set the initial values:
tinymce.init({
selector: 'textarea', // change this value according to your HTML
relative_urls : false,
remove_script_host : true,
document_base_url : 'http://www.mydomain.example/folder/'
});
Upvotes: 1
Views: 1656
Reputation: 229
Another solution that could help, you can use the documentation to create a function that handles this issue TinyMce urlconverter_callback
hence you can add
relative_urls: true
remove_script_host: false
urlconverter_callback : 'customURLConverter'
and For the customURLConverter function you may use something like that
function customURLConverter(url, node, on_save, name)
{
var checkURL;
var urlPrefix;
// Get the first 7 characters of the string
checkURL = url.substring(0, 7);
// Determine if those characters are coming from the image uploader
if(checkURL === "/system")
{
// prefix the incoming URL with my domain
urlPrefix = 'https://www.example.com';
url = urlPrefix.concat(url);
}
// Return URL
return url;
}
Upvotes: 0
Reputation: 2761
This is a really nasty gotcha. Notice the escaped quotes around the url you entered? You have magic_quotes set to on! I've just spent 2 hours tracking this bug down again so I figured I'd better document it on the site.
Before saving the url to the database add:
if (get_magic_quotes_gpc())
foreach ($row as &$value)
$value = stripslashes($value);
This will get rid of the escaped quotes and allow the browser to recognize an absolute url.
Upvotes: 1