[eluser]boytun[/eluser]
Hello
In my application I use the hmvc Strucure to create a widget system.
So in my module, and excatly in the controller, I create the frontend (methode edit) and the backend(methode index) of my widget.
this is the code of the controller wich located in the module folder(widg_html):
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Widg_html extends MX_Controller {
public function __construct()
{
parent::__construct();
$this->load->model('mdl_widg_html_page');
$this->load->model('mdl_widg_html_widget');
$this->load->model('mdl_widg_html');
}
public function index()
{
$this->load->model('mdl_widg_html');
$data['widget_body']=$this->mdl_widg_html->get();
$this->load->view('display',$data);
//echo base_url();
}
public function edit($id = NULL )
{
$this->load->helper('form');
$this->load->library('form_validation');
$this->load->library('session');
if($id){
$this->data['widget']=$this->mdl_widg_html_widget->get($id);
$this->data['widget_body']=$this->mdl_widg_html->get($id);
count($this->data['widget']) || $this->data['error'][]="cette widget n'existe pas";
}
$this->data['values']=$this->mdl_widg_html_page->get();
$this->data['iswidget']='yes';
$this->data['subview']='backend';
$this->data['meta_title']="CMS Hypermedia";
$rules1=$this->mdl_widg_html_widget->rules;
$rules2=$this->mdl_widg_html_page->rules;
$rules3=$this->mdl_widg_html->rules;
$this->form_validation->set_rules($rules1);
$this->form_validation->set_rules($rules2);
$this->form_validation->set_rules($rules3);
if ($this->form_validation->run() == TRUE)
{
$data1=$this->mdl_widg_html_widget->array_from_post(array('position'));
$data2=$this->mdl_widg_html->array_from_post(array('body'));
$this->mdl_widg_html_widget->save($data1, $id);
$this->mdl_widg_html->save($data2, $id);
redirect('admin/widget/');
}
$this->load->view('admin/layout_main', $this->data);
}
}
/* End of file nofun.php */
/* Location: ./application/modules/nofun/controllers/nofun.php */
the strange problem is, that when I use the edit methode everything (mdl_widg_html also)work fun, but when I want to display the widget in the mvc view(I use index methode wich I load the same model mdl_widg_html) , an error came:
Quote:A PHP Error was encountered
Severity: Notice
Message: Undefined property: Widg_html::$mdl_widg_html
Filename: controllers/widg_html.php
Line Number: 16
Fatal error: Call to a member function get() on a non-object in C:\xampp\htdocs\application\modules\widg_html\controllers\widg_html.php on line 15
Please, Help me :/