• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Where is the best place to include inc file??

#4
[eluser]OKIEWARDOYO[/eluser]
Hem, thanks for reply, what about if i have another example like below,
this is my project structure for example,

root/
__application/
____models/
______mymodellang.php

__system/
__lang/
____en.php

__index.php
__.htaccess


look, i have an en.php there,
this en.php contain the code like below, it's an array
Code:
<?
//root/lang/en.php
//language file
$langs = array(
'_Home'=> 'Home',
'_People'=> 'People',
'_News'=> 'News',
'_Blogs'=> 'Blogs',
'_Register'=> 'Register',
'_Login'=> 'Login',
'_Email'=> 'Email',
);
?>

and, i have a mymodellang.php as the model of project,
Code:
<?php
//root/application/models/mymodellang.php

class Mymodellang extends CI_Model {

    function __construct()
    {
        parent::__construct();
    }

    function translate($lang_key){
        @include(LANGPATH.'en.php');

        //global $langs; //i want this global varialbes
        if(in_array($lang_key, array_keys($langs)))
                return $langs[$lang_key];
        else
            return $lang_key;
    }
}
?>

My problem is on my model, my translate function above contain @include(LANGPATH.'en.php');
I want to delete this line of code from the translate function, place it somewhere that can be access by global $langs.

but i don't know where to placed.
i have tried putting like below but no luck,

Code:
<?php
//root/application/models/mymodellang.php
@include(LANGPATH.'en.php');
class Mymodellang extends CI_Model {

    function __construct()
    {
        parent::__construct();
    }
    function translate($lang_key){
      
        global $langs; //i want this global varialbes
        if(in_array($lang_key, array_keys($langs)))
                return $langs[$lang_key];
        else
            return $lang_key;
    }

i want this en.php stay on folder lang/
i don't want to create my_controller or another extra config,
can somebody help me??
thanks


Messages In This Thread
Where is the best place to include inc file?? - by El Forum - 06-22-2012, 03:22 PM
Where is the best place to include inc file?? - by El Forum - 06-22-2012, 03:46 PM
Where is the best place to include inc file?? - by El Forum - 06-22-2012, 10:14 PM
Where is the best place to include inc file?? - by El Forum - 06-23-2012, 03:46 AM
Where is the best place to include inc file?? - by El Forum - 06-23-2012, 09:35 AM
Where is the best place to include inc file?? - by El Forum - 06-23-2012, 11:14 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.