Changing URL segments via a link - 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: Changing URL segments via a link (/showthread.php?tid=28123) |
Changing URL segments via a link - El Forum - 03-02-2010 [eluser]JamesTaylor[/eluser] I have a url which is: domain/index.php/menus/stansfield_arms/bar/appetizers In the url the last 2 segments .../bar/appetizers are being grabbed by the controller function and used to query the DB in order to return menu items. The 2 segments relates to the menu type ('bar menu' or 'a la carte') and the menu section ('appetizers' / 'main course' / 'desserts') I have a number of links on the page to display the various sections of the menu - i.e main courses / desserts etc. so when a user clicks the link for main courses of the bar menu the url would become: domain/index.php/menus/stansfield_arms/bar/maincourses if its the 'a la carte starters' the url would become: domain/index.php/menus/stansfield_arms/alacarte/starters What is the easiest way to just change the last 2 sements of the url via my links whilst still keeping segments 1 and 2 as they are? Changing URL segments via a link - El Forum - 03-02-2010 [eluser]danmontgomery[/eluser] http://ellislab.com/codeigniter/user-guide/libraries/uri.html Code: anchor('menus/stansfield_arms/' . $this->uri->segment(3) . '/maincourses', 'some text'); Changing URL segments via a link - El Forum - 03-02-2010 [eluser]JamesTaylor[/eluser] I wondered if there was a shorthand sytax for along the lines of base_url() or current_url()... obviously not! Cheers! |