The last param, false, tells Cake to not escape the "title" (your image, in this case). But you need to pass an 'escape' option in $htmlAttributes to keep them from being escaped, also.
echo $html->link( $html->image('navigation/nlOn-curved.gif'), 'http://www.external.com', array( 'onmousever'=>'changeImages("nav01", "images/nlOn-curved.gif");return true;', 'escape' => false ), null, false ); HOWEVER, there seems to be a bug in HtmlHelper, which I've posted to Trac. [1] I think the Cake devs are trying to move as many params as possible into array options, so that they may easily be handed down the chain of methods. In this case, the link() method checks for that false param to see if the title requires escaping, but it also looks in $htmlAttributes for an escape option. If it's there, the title is also escaped. The problem, though, is that the option is then unset before the array is handed off to create the link attributes. The fix is to comment the unset() line: if (isset($htmlAttributes['escape'])) { $escapeTitle = $htmlAttributes['escape']; //unset($htmlAttributes['escape']); } I guess the reasoning was that the 'escape' option was no longer needed. But that fails to recognise that this option already had a purpose before it was drafted into service controlling the escaping of the link text ($title). [1] https://trac.cakephp.org/ticket/6071 On Sat, Feb 7, 2009 at 2:15 AM, Zolthar <zolt...@gmail.com> wrote: > > Thanks for the update, I had tried something similar, although did not > succeed as quotes were converted to ". > > Here is what I attempted: > <?php echo $html->link( > $html->image('navigation/nlOn-curved.gif'), > 'http://www.external.com', > array( > 'onmousever'=>'changeImages("nav01", > "images/nlOn-curved.gif"); > return true;' > ), > null, false) ?> > > Although the above turned out to be: > <a href="http://www.external.com" onmousever="changeImages > ("nav01", "images/nlOn-curved.gif"); return > true;"><img src="/wplam/img/navigation/nlOn-curved.gif" alt="" /></a> > > So I must be missing something here. Is there a way to force or escape > the quote to be literal as opposed to being converted? > > > > > On Feb 7, 4:10 pm, Simz <ouellet.si...@gmail.com> wrote: >> use the html helper >> :http://book.cakephp.org/view/206/Inserting-Well-Formatted-elements >> >> image(string $path, array $htmlAttributes = array()) >> >> in your view (inside a php block) >> >> echo $html->image( >> "menu1.jpg", >> array( >> "onmouseover"=>"yourJsRollOverFunc()", >> "onclick"=>"jsFunc()", >> "class"=>"mycssclass" >> ) >> ); >> >> wrap the php block with your link... >> this should do the trick >> >> On Feb 6, 10:14 pm, Zolthar <zolt...@gmail.com> wrote: >> >> > Learning cake/programming for the first time so please excuse me if >> > this is a very noob question. I have tried to search this board >> > without much success - as the responses were either too complicated or >> > possibly I searching with the wrong keywords. >> >> > What I am after is how do I get a linked image to swap like >> > onmouseover using javascripts (or any other option)? > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---