CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9

Thread: tinyMCE - Alter url

  1. #1
    Join Date
    Nov 2004
    Posts
    187

    tinyMCE - Alter url

    Im using tinyMCE and when I send my text with an url this is what I get:

    Code:
    <p><a href=\"aaa\" target=\"_blank\">asdas</a></p>
    How can I do to normalize it?
    Id like to get:
    <p><a href='aaa' target='_blank'>asdas</a></p>

    Ive tried
    Code:
    $txt = str_replace("/\/","", $_POST['text']);
    $txt = str_replace('"',"'", $txt);
    Didnt work.

  2. #2
    PeejAvery's Avatar
    PeejAvery is offline Super Moderator Power Poster
    Join Date
    May 2002
    Posts
    10,943

    Re: tinyMCE - Alter url

    Why don't you just use stripslashes()?
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  3. #3
    Join Date
    Nov 2004
    Posts
    187

    Re: tinyMCE - Alter url

    Right. I could do that but I&#180;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://../
    Last edited by rogernem; November 30th, 2009 at 05:47 PM.

  4. #4
    PeejAvery's Avatar
    PeejAvery is offline Super Moderator Power Poster
    Join Date
    May 2002
    Posts
    10,943

    Re: tinyMCE - Alter url

    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.

    PHP Code:
    $txt stripslashes($_POST['text']); 
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  5. #5
    Join Date
    Nov 2004
    Posts
    187

    Re: tinyMCE - Alter url

    I did exactly like that: $txt = stripslashes($_POST['text']);

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

    With my code
    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
    Last edited by rogernem; November 30th, 2009 at 06:43 PM.

  6. #6
    PeejAvery's Avatar
    PeejAvery is offline Super Moderator Power Poster
    Join Date
    May 2002
    Posts
    10,943

    Re: tinyMCE - Alter url

    What is the exact return of the posted variable text? Can you put it in &#91;quote&#93; tags?
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  7. #7
    Join Date
    Nov 2004
    Posts
    187

    Re: tinyMCE - Alter url

    this is the return

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

  8. #8
    PeejAvery's Avatar
    PeejAvery is offline Super Moderator Power Poster
    Join Date
    May 2002
    Posts
    10,943

    Re: tinyMCE - Alter url

    Try the following...

    PHP Code:
    preg_match('/site \(<a href="(.*?)"/i'$_POST['text'], $matches);
    echo 
    '<p><a href="' $matches[1] . '" target="_blank">' $matches[1] . '</a></p>'
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  9. #9
    Join Date
    Nov 2004
    Posts
    187

    Re: tinyMCE - Alter url

    For some reason tinymce was replacing the url with ../
    I downloaded the new version and doing the following it worked

    tinyMCE
    Code:
    convert_urls : false
    PHP
    Code:
    $txt= stripslashes($_POST['txt']); 
    $txt= str_replace('"',"'", $txt);
    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)