Welcome Guest, Not a member yet? Register   Sign In
anchor function
#1

[eluser]cinewbie81[/eluser]
Hi all, i'm very new to CI.. Can anyone help with my following question:

I want to have an image, after clicked on that image i want it to go to the controller's function .. So instead of write :

anchor('dbbackup/backup', 'Backup'), i want something like

anchor('dbbackup/backup', 'img src = '/home/eddy/myicon.jpg') - Of course this doesn't work ...


anyone can tell me how ?

thanks
#2

[eluser]danoph[/eluser]
use old fashioned html Smile

Code:
<a href="url" title="link to somewhere"><img src="image url" alt="image keywords" alt="image description"></a>
#3

[eluser]Armchair Samurai[/eluser]
I agree that HTML would be better, but if you feel compelled to do it the hard way:

Code:
&lt;?=anchor('ci_uri/here','<img src="/path/to/img.jpg" alt="" />', 'attribute="here"');?&gt;

Just note that you must have the attribute parameter or CI will parse things incorrectly. Alternately, you can reverse the quotes for the text parameter and drop the attribute parameter, but that will leave you with HTML markup for your anchor title.
#4

[eluser]Eric Cope[/eluser]
I would rather use the anchor function in case you are dynamically generating CI-sensitive URIs, at least that was why I wanted to use that function.
#5

[eluser]nmweb[/eluser]
You can also create a new helper to do the job for you. It shouldn't be too hard to code.
#6

[eluser]Developer13[/eluser]
[quote author="danoph" date="1192440683"]use old fashioned html Smile

Code:
<a href="url" title="link to somewhere"><img src="image url" alt="image keywords" alt="image description"></a>
[/quote]

That would be quite counterproductive in a CI environment, don't you think?
#7

[eluser]danoph[/eluser]
yes, but then its xhtml valid, if that matters.




Theme © iAndrew 2016 - Forum software by © MyBB