php - CodeIgniter behaviour, constructors and routes -


I'm using CodeIgniter 2.0 for the first time to create a multilingual site where the home page has a slide show. I am developing it on my laptop - Localhost / website /.

I am using the routes. To specify the php file, http: // local host / website / language / page_id / some-page-title to define variables depending on which language format format. Returns the English page of http: // localhost / website / en / 1 / home-page Page_ id 1.

The root file is:

  $ route ['default_controller'] = "content"; $ Route ['n / (: number) / (: any)'] = "content / n / $ 1"; $ Route ['d / (: number) / (: any)'] = "content / day / $ 1"; $ Route ['es / (: num) / (: any)'] = "content / es / $ 1"; An example of a language function (n function) in content configuration is:  
  public function n ($ page_id) {$ language = "n"; $ Lang_array ['css'] = "base.css"; $ This- & gt; Get_content ($ page_id, $ lang_array);  

$ Lang_array ['language'] = "n"; $ Lang_array ['css'] = "base.css"; $ This- & gt; Get_content ($ page_id, $ language); }

My problem is that when I go to http: // localhost / website / everything works well with a slideshow. However, when I go to URL http: // localhost / website / en / 1 / home-page , all works except slides in slideshow (even if they both execute the same code And the HTML output is the same when I look at the source view on the page).

The only thing I could think of is that if I were to just http; // localhost / website / then the index function will be called which activates the constructor, but if I enter http: // localhost / website / en / 1 / home-page Then index and thus the manufacturer overlooks. Although do not know why other things still work but the picture does not slideshow. Do you think this is the reason? Any solution?

Thanks

TOM

Can I think That is not possible with some sort of JavaScript error on any undefined variable, $ lang_array ['language'].

In the index, you set the key to 'N',

  public function index () {// setting when coming directly to the home page or url $ Page_id = 1 does not contain any language; $ Lang_array ['language'] = "n"; $ Lang_array ['css'] = "base.css"; $ This- & gt; Get_content ($ page_id, $ language); }  

but in the N method, you

  public function n ($ page_id) {$ language = "n"; $ Lang_array ['css'] = "base.css"; $ This- & gt; Get_content ($ page_id, $ lang_array);  

}

Since they look very similar, you should summarize the same behavior in a personal function, or perhaps send the language as an absolute The route should be modified. For a function.


Comments

Popular posts from this blog

HTML/CSS - Automatically set height width from background image? -

php - Mysql Show Process - Sleep Commands and what to do -