CodeIgniter Forums
What is the best way to store a variable(state)? - 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: What is the best way to store a variable(state)? (/showthread.php?tid=52379)



What is the best way to store a variable(state)? - El Forum - 06-08-2012

[eluser]Unknown[/eluser]
Hi to all!

I'm new in CodeIgniter and I have a pretty basic question.

Say that I have a multilanguage site (english + greek).

The site starts with 2 language buttons.

What is the best way to store the language state (according to which button the user pressed)?

Should I use sessions or something else?

An the same goes for my menu.

What is the best way to find out whenever use a controller to which part of the site you are (for example I have clicked the 2nd menu btn and after that the 3rd submenu btn).

Should I use sessions again to store the current menu states?

Thanx a lot for any answers.

Cheers!


What is the best way to store a variable(state)? - El Forum - 06-08-2012

[eluser]LuckyFella73[/eluser]
Hi and welcome to the forums!

To solve your language issue have a look at this page:
http://maestric.com/doc/php/codeigniter_i18n

For your second question: via your url segments you allways
know which controller and method is "active". Reading an processing
that information you don't need to store that somehow.

More about URIs in Codeigniter:
http://ellislab.com/codeigniter/user-guide/libraries/uri.html
http://ellislab.com/codeigniter/user-guide/helpers/url_helper.html

Hope that helps - cheers


What is the best way to store a variable(state)? - El Forum - 06-08-2012

[eluser]Unknown[/eluser]
Wow! That was fast! Thanx a lot.

Regarding the language question, I'll dig in the link you gave me. It seems great!

Regarding the menu question, from what I get is when I click a menu button, it should redirect me to a url like this

home/menu_generate/menubtn2/submenubtn3/submenubtn4

and pass the menubtn2, submenubtn3 and submenubtn4 uri segments to the menu_generate function right?

Thanx again.

Cheers