Welcome Guest, Not a member yet? Register   Sign In
it is possible a anchor with image?
#1

[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
anchor('home','<img src="...">');
?&gt;

I see the image with a link but adds "> next to the image.

Sorry for my school English and thanks in advance,
-- Isern Palaus
#2

[eluser]Michael Wales[/eluser]
I've used the following no problem many times before:

Code:
anchor('controller/segment', '<img src="myimage.jpg" />');
#3

[eluser]Armchair Samurai[/eluser]
You need the third parameter or the anchor function will parse things incorrectly if you are using single quotes.

Code:
&lt;?=anchor('foo/bar', '<img src="/path/to/image" alt="" />', 'title="whatever"');?&gt;

See this thread for a more in depth explanation.
#4

[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.
#5

[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.
#6

[eluser]ejangi[/eluser]
I thought the third parameter needed to be an array:
Code:
&lt;?=anchor('foo/bar', '<img src="/path/to/image" alt="" />', array('title' => "whatever"));?&gt;
#7

[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.
#8

[eluser]ejangi[/eluser]
Ah okay, very good. I should have looked at the code before posting... Tongue




Theme © iAndrew 2016 - Forum software by © MyBB