Click to See Complete Forum and Search --> : tinyMCE - Alter url


rogernem
November 30th, 2009, 12:37 PM
I´m using tinyMCE and when I send my text with an url this is what I get:


<p><a href=\"aaa\" target=\"_blank\">asdas</a></p>


How can I do to normalize it?
I´d like to get:
<p><a href='aaa' target='_blank'>asdas</a></p>

I´ve tried

$txt = str_replace("/\/","", $_POST['text']);
$txt = str_replace('"',"'", $txt);


Didn´t work.

PeejAvery
November 30th, 2009, 03:50 PM
Why don't you just use stripslashes() (http://us3.php.net/manual/en/function.stripslashes.php)?

rogernem
November 30th, 2009, 04:10 PM
Right. I could do that but I´d like to know what I should do to get that piece of code working
And if I do that for the link http://www.site.com I get http://../

PeejAvery
November 30th, 2009, 05:13 PM
The code you posted is a waste. Use the following. If that isn't returning what you want, then the posted variable is incorrect. If that is the case, then we need more relevant code.

$txt = stripslashes($_POST['text']);

rogernem
November 30th, 2009, 05:38 PM
I did exactly like that: $txt = stripslashes($_POST['text']);

But its not returning what I need. I think it is a tinyMCE issue.
That´s why I was trying to use my code.

With my code

$txt = stripslashes($_POST['txt']);
$txt = str_replace('"',"'", $txt);


Im getting:
<a href='..//' target='_blank'>http://www.site.com</a>
site (<a href='http://test.site.com' target='_blank'> -> THIS IS THE ONLY ONE NOT LOSING THE LINK

What is the other solution? Any other ideas?
Thanks

PeejAvery
November 30th, 2009, 05:51 PM
What is the exact return of the posted variable text? Can you put it in [quote] tags?

rogernem
December 1st, 2009, 10:19 AM
this is the return


<a href="..//" target="_blank">http://www.site.com</a>
site (<a href="http://test.site.com" target="_blank">

PeejAvery
December 1st, 2009, 10:58 AM
Try the following...

preg_match('/site \(<a href="(.*?)"/i', $_POST['text'], $matches);
echo '<p><a href="' . $matches[1] . '" target="_blank">' . $matches[1] . '</a></p>';

rogernem
December 1st, 2009, 12:17 PM
For some reason tinymce was replacing the url with ../
I downloaded the new version and doing the following it worked

tinyMCE

convert_urls : false


PHP

$txt= stripslashes($_POST['txt']);
$txt= str_replace('"',"'", $txt);


Thanks