how can i load fifférent modules in the same controllers?

#1
[eluser]haythem01[/eluser]
how can i load fifférent modules in the same controllers for exapmle module news and pages
in the same page (controller)?
please if you have response contact me, thnaks

#2
[eluser]Tri Dang[/eluser]
Hi,
What do you mean by "modules" in term of CI development?

#3
[eluser]haythem01[/eluser]
i mean by "modules" -> models
because when i load different models in the same controllers i have an errors
plz help me and thanks my friend.

#4
[eluser]Unknown[/eluser]
$this->load->model('model_1');
$this->load->model('model_2');

// then you can invoke the methods like this:

$this->model_1->some_method_in_model_1();

$this->model_2->some_method_in_model_2();

#5
[eluser]haythem01[/eluser]
thank you very much my friend you are veryyyyyyy gentil

#6
[eluser]haythem01[/eluser]
my freind i have put like you have say to me but in the scrren i have got the content of page "pages" and not content of "news"
function News()
{
parent::Controller();

$this->table ="news";
$this->table ="pages";
$this->template['module'] ="pages";
$this->template['module'] ="news";
//$this->template['module'] ="pages";
//appel au model on la défini sous le nom page
$this->load->model('News_Model','news',true);
$this->load->model('Pages_Model','page',true);


//$this->load->model('Pages_Model','page',true);

//$this->template['navigation']=$this->page->nav();
$this->template['news_']=$this->news->news_();
}

and in the models i put:

function News_Model()
{
parent::Model();
$this->table= "news";
$this->table= "pages";
}

function get($path)
{
//$this->db->where('path',$path);
$this->db->where('active',true);
$query=$this->db->get($this->table,1);
if($query->num_rows()==1)
{
return $query->row_array();
}
else
{
//false
return false;
}
}

function nav()
{
$this->db->select('title,menu_title,path');
$this->db->where('active',true);
$this->db->orderby('menu_title');
$query=$this->db->get($this->table);

if($query->num_rows()>0)
{
return $query->result_array();
}
}

i would like to write some function of model page like the navigation(); sorry i cant' speek english very well

#7
[eluser]Tri Dang[/eluser]
Hi,
I find no news_() method in your News_Model that you tried to call.

#8
[eluser]haythem01[/eluser]
function news_()
{
$this->db->select('title, body, id');
$this->db->where('active',true);
$this->db->orderby('id');
$query=$this->db->get($this->table);

if($query->num_rows()>0)
{
return $query->result_array();
}
}

i have pu this fuction but he select from the table "pages" then all content is from this tables
i want to show links that is puted in the tables pages and content of news puted in the tables news in the same page, thanks you for your response my friend

#9
[eluser]Tri Dang[/eluser]
Code:
function News_Model()
      {
        parent::Model();
        $this->table= “news”;
        $this->table= “pages”;
      }
The second assignment override the first one.

#10
[eluser]haythem01[/eluser]
but if i put:
$this->table= “pages”; before
$this->table= “news”;

i have an error:

Champ 'menu_title' inconnu dans field list
SELECT `title`, `menu_title`, `path` FROM (`ci_news`) WHERE `active` = 1 ORDER BY `menu_title`

=>because `title`, `menu_title`, `path` is from (`ci_pages`)


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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