Several html elements inside an anchor tag, with CI's anchor funtion |
[eluser]Joures[/eluser]
Hi, i'm trying to get an image tag and a span tag inside an anchor tag using CI's anchor function, to no success. Anyone has any idea how to do this? I've succeeded in getting the image inside the tags but can't figure out how to get the span inside there too. Help greatly appriciated.
[eluser]Bart Mebane[/eluser]
I haven't tried it, but you should be able to use any text you want, including html tags. How about Code: <?php echo anchor('news/article', '<img src="picture.jpg" /><span>some text</span>') ?>
[eluser]InsiteFX[/eluser]
you can also pass a third parameter as an associative array. InsiteFX
[eluser]Joures[/eluser]
[quote author="InsiteFX" date="1291200222"]you can also pass a third parameter as an associative array. InsiteFX[/quote] As kind of a noob to php in general i have to ask, how would one do that?
[eluser]LuckyFella73[/eluser]
By passing an associative array you can add attributes to the link tag - for example: Code: <?php See: http://ellislab.com/codeigniter/user-gui...elper.html
[eluser]teampoop[/eluser]
You can also use functions that output text inside the second argument, which will output the same text as Bart mentioned.. Code: <?php echo anchor('news/article', img('picture.jpg').'<span>some text</span>') ?> On a side note, the third parameter on the anchor function is an array that would only change the attributes of the <a> tag. Not affect the innerHTML. again, I could be wrong.
[eluser]Dennis Rasmussen[/eluser]
If anchor() makes it too complicated for you then don't use it :S It's just a helper for quick tags.
[eluser]TwoConnect[/eluser]
Personally, I stay away from the anchor tag. It makes things 10 times more complicated in my opinion
[eluser]techgnome[/eluser]
Really? I find the opposite true. Especially when it comes to making links within a loop where very little changes. I can set the assoc array once, loop while passing the text and link info, and the array. Done. But eh... to each their own. -tg |
Welcome Guest, Not a member yet? Register Sign In |