Welcome Guest, Not a member yet? Register   Sign In
include in codeigniter
#1

[eluser]Unknown[/eluser]
Hi everybody I try to discover codeigniter, so I want to know who I can make include with codeigniter
thank u
#2

[eluser]CroNiX[/eluser]
Can you be more specific on what you're trying to do?
#3

[eluser]dalirnet[/eluser]
include model in controller
Code:
$this->load->model('model_name');
include library in controller
Code:
$this->load->library('lib_name');
include controller in controller using helper
for example
Code:
function call_cn($class)
{
include_once(APPPATH.'controllers/'.$class.'.php');
$call_cn = new $class();
return $call_cn;
}
and call helper function in controller
Code:
$test = call_cn('controller_name');
$test->method();
might be a better way Confusedmirk:
#4

[eluser]jonez[/eluser]
I'd strongly recommend against calling one controller from another as it goes against everything MVC stands for and is sure to lead to horrible spaghetti code.
#5

[eluser]dalirnet[/eluser]
I would not recommend using(load cn in cn)
just a way for every who are looking for this(load cn in cn)
Quote:might be a better way
I'm using a library and recommend this
and it is different with spaghetti code
#6

[eluser]CroNiX[/eluser]
If you need to load controller in a controller, that should tell you it should be a library called by both controllers.
#7

[eluser]dalirnet[/eluser]
thanks
but i don't need to this (call cn in cn)
Quote:just a way for every who are looking for this
#8

[eluser]ivantcholakov[/eluser]
Loading a controller within a controller is a very stupid idea. HMVC is the right idea.
#9

[eluser]dalirnet[/eluser]
[quote author="ivantcholakov" date="1407510913"]Loading a controller within a controller is a very stupid idea. HMVC is the right idea.[/quote]
this true / i agree /HMVC is the right idea
#10

[eluser]dalirnet[/eluser]
can i answer with the persian lang??
do you can translate persian??




Theme © iAndrew 2016 - Forum software by © MyBB