[newbie] function after anchor click |
[eluser]phusiondesign[/eluser]
Sorry for the hand holding... all of the ci fog hasn't cleared yet. Ok, I have this anchor which when clicked I want to perform a function then redirect to the url in the anchor. Example below... Code: anchor($ci->link_click($link->url,$link->id,$link->clicks),$link->title) Now as you can probably tell, the 'link_click' function is executing when the page loads. How do I prevent this and make it so that it only executes when I click that anchor. Thanks in advance.
[eluser]Armchair Samurai[/eluser]
Pass your three variables as part of the url, then redirect from the function: Code: anchor("foo/bar/$link->url/$link->id/$link->clicks", $link->title);
[eluser]phusiondesign[/eluser]
Thanks. I think this will work except that I am running into a problem when I am passing a full URL, I believe because of the slashes. Code: http://ex.com/foo/bar/2/5/http://www.google.com It gets all the way to the redirect and then... redirects to 'http:' Any thoughts?
[eluser]Armchair Samurai[/eluser]
Yeah... out of the box, CI doesn't allow slashes. You can either modify your config.php to allow slashes, or pass the url without the "http://" and add it in your function, something like Code: // You'll need to have the URL Helper loaded if you want to use prep_url()
[eluser]phusiondesign[/eluser]
Thanks for the help... but I avoided the issue altogether by just passing the entry id and accessing the database to get the url and clicks. |
Welcome Guest, Not a member yet? Register Sign In |