it is possible a anchor with image? |
[eluser]Isern Palaus[/eluser]
Hello, I'm newbie in Code Igniter as a programmer and i usually use anchor() function to create the links. Now I've a a images that needs to be a link, how can I apply some function like anchor? If I use Code: <?php I see the image with a link but adds "> next to the image. Sorry for my school English and thanks in advance, -- Isern Palaus
[eluser]Michael Wales[/eluser]
I've used the following no problem many times before: Code: anchor('controller/segment', '<img src="myimage.jpg" />');
[eluser]Armchair Samurai[/eluser]
You need the third parameter or the anchor function will parse things incorrectly if you are using single quotes. Code: <?=anchor('foo/bar', '<img src="/path/to/image" alt="" />', 'title="whatever"');?> See this thread for a more in depth explanation.
[eluser]Isern Palaus[/eluser]
Thanks both for your replies, I'll try it. Michael Wales I'm using it like you and doesn't works. I'll try the third parameter like Armchair said. Thanks another time.
[eluser]Michael Wales[/eluser]
You know the third parameter thing might work - I've never used it without the third parameter, so that could very well be the issue.
[eluser]ejangi[/eluser]
I thought the third parameter needed to be an array: Code: <?=anchor('foo/bar', '<img src="/path/to/image" alt="" />', array('title' => "whatever"));?>
[eluser]Michael Wales[/eluser]
If you are only passing one parameter it can be a string I believe, most of CI helpers work this way. It's best to go ahead and make it an array though - it saves the library from doing it itself.
[eluser]ejangi[/eluser]
Ah okay, very good. I should have looked at the code before posting... |
Welcome Guest, Not a member yet? Register Sign In |