What I want to do is convert the following to work with CakePHP:
<a href="URL ADDRESS"><img src="URL OF THE FIRST IMAGE GOES HERE" onmouseover="this.src='URL OF THE SECOND IMAGE GOES HERE'" onmouseout="this.src='URL OF THE FIRST IMAGE GOES HERE'" /></a>
I have the following so far:
<?php echo $this->Html->image("animalhealth.png", array(
"alt" => "Animal Health",
"onmouseover" => "this.src='animalhealthhover.png'",
"onmouseout" => "this.src='animalhealth.png'",
'url' => array('controller' => 'records', 'action' => 'index'
)
)); ?>
The problem are the onmouseover & onmouseout event lines. I need to tell cake to somehow use the helper method otherwise it just selects no image. I don’t want to have to put the entire address in as the is a navigation menu and there will be multiple instances of the app at different locations.
I have managed to build a work around using CSS.
Made a custom image for the button Icon.
This is what goes in the view/layout page:
If your not using cakePHP you could do it like this in a normal HTML page:
This Makes both the text and the icon clickable.
Then the CSS:
This makes a nice button with 2 rounded top corners. When you hover over the button anywhere the background and text colours transition between each other. ie: text goes from blue to orange and background goes from orange to blue.
Note about #button_name:hover a:
You must set it as specified if you set it as “button_name a:hover” the text will stay the same color as the background.
Hopefully this will help someone else.
Still keen to hear any ideas about doing it with the JS.