![]() |
anchor with image - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: anchor with image (/showthread.php?tid=48486) |
anchor with image - El Forum - 01-18-2012 [eluser]pierpads[/eluser] Hello to everyone! I've got a problem with an anchor containing an image: echo anchor('controllerPrivato/visualizzaPagina',img($banner_image)); where $banner_image contains the src and the id of the image. The problem is: I need that when someone clicks on the image, it redirects on a specific page with a certain id_page (I have a separated variable for that id_page). How can I append the page_id to this anchor? (controllerPrivato/visualizzaPagina) waits for a $_POST variable, is that possible to pass it such a variable by the anchor?? thank you very much for help. anchor with image - El Forum - 01-18-2012 [eluser]johnpeace[/eluser] Code: echo anchor(‘controllerPrivato/visualizzaPagina/’ . $id_page, img($banner_image)); Like that? You could get your controller to look for the post var, if it's not found, look for a uri segment with an int and use THAT as the var you want. anchor with image - El Forum - 01-18-2012 [eluser]pierpads[/eluser] Hello, thanks for reply... I already tried that solution out, but this generates something like "...visualizzaPagina4" ( 4 is just as example ). I need to pass the variable itself, so that I can retrieve it from the controller ( something like $var=$this->input->post('id_page') ). Thank you again. anchor with image - El Forum - 01-18-2012 [eluser]pierpads[/eluser] sorry I didn't read the whole post. I'll try it looking for the segment, thank you very much. anchor with image - El Forum - 01-18-2012 [eluser]InsiteFX[/eluser] How about a hidden form input field? anchor with image - El Forum - 01-18-2012 [eluser]johnpeace[/eluser] Code: if ($this->input->post('id_page') == '') { Something like this should work... anchor with image - El Forum - 01-18-2012 [eluser]johnpeace[/eluser] [quote author="InsiteFX" date="1326918268"]How about a hidden form input field? [/quote] But clicking a link doesn't submit the form... anchor with image - El Forum - 01-18-2012 [eluser]TWP Marketing[/eluser] [EDIT] in the time it took to write this, you have several other replies, so this may be irrelevant... [quote author="pierpads" date="1326913594"]Hello to everyone! I've got a problem with an anchor containing an image: echo anchor('controllerPrivato/visualizzaPagina',img($banner_image)); where $banner_image contains the src and the id of the image. The problem is: I need that when someone clicks on the image, it redirects on a specific page with a certain id_page (I have a separated variable for that id_page). How can I append the page_id to this anchor? (controllerPrivato/visualizzaPagina) waits for a $_POST variable, is that possible to pass it such a variable by the anchor?? thank you very much for help. [/quote] First, please use the [ code][/ code] tags when posting code, it is easier to read. You will find information about the img() helper here: http://ellislab.com/codeigniter/user-guide/helpers/html_helper.html#img You may add the id_page parameter to the url string in the anchor() helper: Code: ... You may then read the $_POST data, perhaps using the uri class library to read the segments: http://ellislab.com/codeigniter/user-guide/libraries/uri.html For instance: Code: ... anchor with image - El Forum - 01-18-2012 [eluser]pierpads[/eluser] Thank you very much , it works perfectly!! I am integrating nivo slider to a web site and I couldn't get solution. I am sorry for the code tag, it was my first topic here to get help. I'll sure use it the next time. |