CodeIgniter Forums

Full Version: Slug from database available on all pages through lang CodeIgniter
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have a table on my database from where I get some slug texts:

and display on my website through

PHP Code:
<?php echo lang($slug_from_database); ?>
I use this method as LanguageSwticher:

So in My_Controller.php I have in construct:

PHP Code:
$this->categories_list $this->categories_model->entries();
$list_categories['categories'] = $this->categories_list;
$this->data['sidebar_categories'] = $this->load->view('blocks/sidebar_categories'$list_categoriesTRUE); 

and all the categories are available on all pages from my website.

The problem is when I send the categories to the view, the language is not fired up from the LanguageLoader.php controller. LanguageLoader is initialised in hooks.php (post_controller_constructor - see the link example) BEFORE the my_controller construct. If no language no text on echo $slug_from_database. How do you suggest to do?
You did not read my problem.

I found one solution:


PHP Code:
       public function LanguageLoader() {

       $site_lang $this->session->userdata('site_lang');
       if ($site_lang) {
       } else {


in MY_Controller.php

and call it in the constructor:
PHP Code:

and delete

PHP Code:
   $hook['post_controller_constructor'] = array(
   'class' => 'LanguageLoader',
   'function' => 'initialize',
   'filename' => 'LanguageLoader.php',
   'filepath' => 'hooks'

from hooks.php so now I load the language in controller`s construct not with hook. What can you tell me about this?