Re: Php Code inside a link does not work

  •  05-10-2008, 8:46 AM

    Re: Php Code inside a link does not work

    Hi Adam,
     
    I cannot tell you "thanks" to solve my problem. I give here the solution because I'm pretty sure it can be very useful for some PHP programmers.
     
    First of all, I discover when the problem appears. On your demo website, I wrote the following strings in HTML mode :
     
    <a target="_blank"
    href="<?php echo getUrlRedirect('../../', 'http://www.test.co.uk/'); ?>">Test</a>
    <a href="<?php echo getUrlRedirect('../../', 'http://www.test.co.uk/'); ?>" target="_blank" >Test</a>
     
     Go in Normal Mode, then in HTML mode, you get that :
     
     <a target="_blank" href="%3C?php%20echo%20getUrlRedirect%28%27../../%27,%20%27http://www.scrapandstamp.co.uk/%27%29;%20?%3E">Test</a>
    <a href="&lt;?php echo getUrlRedirect('../../', 'http://www.scrapandstamp.co.uk/'); ?&gt;" target="_blank">Test</a>
     
     These two links are exactely the same, the only difference it's the carriage return for the first one (just after _blank") that give an href translation with an urlencode function, not for the second one.
     
    My solution. When I retrieve the resulting string from CuteEditor in $_POST['id'], I convert like that :
     
    str_replace(array('&lt;?','?&gt;'),array('<?','?>'),urldecode($_POST['id']))
     
    That's all, now I can edit php code inside links, but the number of tests and days to think about was a bit huge !
     
    Otherwise, CuteEditor is a fabulous HTML editor....I will upgrade my license.
     
    AlES
     

View Complete Thread