Welcome Guest, Not a member yet? Register   Sign In
Changing URL segments via a link
#1

[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?
#2

[eluser]danmontgomery[/eluser]
http://ellislab.com/codeigniter/user-gui...s/uri.html

Code:
anchor('menus/stansfield_arms/' . $this->uri->segment(3) . '/maincourses', 'some text');
#3

[eluser]JamesTaylor[/eluser]
I wondered if there was a shorthand sytax for along the lines of base_url() or current_url()... obviously not!

Cheers!




Theme © iAndrew 2016 - Forum software by © MyBB