Newbie: urls Relative to Controller - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Newbie: urls Relative to Controller (/showthread.php?tid=27517) |
Newbie: urls Relative to Controller - El Forum - 02-13-2010 [eluser]Unknown[/eluser] Just getting started with CodeIgniter, and I'm having a problem with urls that I cannot figure out. I call a controller (e.g. 'index.php/orgs/'). It calls the index function in the orgs controller, which loads a view. In the view, I use the url helper function: <?=anchor('orgs/edit/'.$org->id, 'Edit') ?> The resulting link is index.php/orgs/edit/1. If I don't use the helper function (just use a href=), I get: index.php/orgs/orgs/edit/1. Okay, so I'll use the helper function, but in the tutorials, relative links seem to work with or without the helper functions. What am I missing? Newbie: urls Relative to Controller - El Forum - 02-13-2010 [eluser]Shay Falador[/eluser] Use the url helper, and then just do: Code: <a href="<?php echo site_url('orgs/edit/'.$org->id); ?>">Edit</a> If you don't want to use url helper you can call site_url from the url library.. |