Welcome Guest, Not a member yet? Register   Sign In
Loading model to Router (please direct me)
#1

[eluser]dmitrybelyakov[/eluser]
Hello.

I am a complete Newbie with Codeigniter so maybe my question's a bit silly.
I started coding and learning the framework simultaneously.

So the question is:

I need to detect the first part of url segment and find out if it is a language marker.
Like: www.site.com/eng/ OR www.site.com/fin/ and then set this value to the config array for future use by models and controllers. (By the way is setting it to config array a good practice?)

It should be done before everything else so I decided to do it in Router. I created my own MY_Router to overwrite some default routing functions such as url exploding.

I then need to check database to find out if the first url segment is a registered language or not. As languages are free for administrator to set up - I created a model to work with database and handle all get-language-routines.

So my problem is that I cannot load the Languages model in MY_Router to get a list of existing languages.

So what have I tried:

$this->load->model does not work in Router
Autoloading model does not work in Router
Getting $CI instance and loading model does not work either.

I would very much appreciate any help or guidance because now i feel like missing some basic concepts of framework. Is my logic/algorithm fine or am I doing something wrong?


Thanks.
#2

[eluser]dmitrybelyakov[/eluser]
I feel like i should describe the logic of what i'm doing a little bit more:

There are 3 cases how we can get our language set through url:

1. www.site.com (no url parts) - then the language marked in databese as default will be set in config

2. www.site.com/eng/news/posts/ (got url parts) detect if the first part of url is a language prefix (check in databese). If it is - set to config & strip it off the url. If it's not - net set default language.


So basicly it's done like this.




Theme © iAndrew 2016 - Forum software by © MyBB