1

I have a project and have run into a problem. I use Codeigniter HMVC and therefore build modules. I appreciate your help. Thanks.

I have two module methods where one calls another. The other delivers a database result and loads it into a view that is then passed on to the template from the 1st module method. I now realize, that since I get a view and not data from the 2nd module, I don't see how I can check if there is a database record returned, and I don't want another database call just for that purpose. The seperation between "item" and "description" modules is required. Having data sent instead would make a really messy structure that to my understanding would counteract the HMVC structure. I therefore need to keep this structure. How can I check if database record exists and only run the 1st method if it does? Please advise. Thanks

1st module (controller method) called through URL

function view_item($item_id) 
{    

    $data['item_id'] = $item_id;       
    $data['item'] = $this->item;  
    $data['item_group'] = $this->item_group;  
    $data['content_module'] = Modules::run("descriptions/view",$item_id); 
    $data['active_menu_item'] = "descriptions";
    $data['view_file'] = "handle_view";
    $data['module'] = $this->module;
    $template = "application";      
    $this->load->module('templates');
    $this->load->templates->$template($data); 

}

2nd module method called by 1st module method

function view($item_id)
{
    $data['title'] = "View description";
    $data['page_title'] = "View description";
    $data['page_subtitle'] = "This item";              
    $data['item_id'] = $item_id;
    $array = array('item_id'=> $item_id,'group_id'=> $this->group_id);
    $object = $this->get_where_custom($array);
    $num_rows = $object->num_rows;
    $descriptions =  $object->result();
    $data['description'] =  $descriptions[0];
    $this->load->view('view_view',$data); 

} 
nicolaib
  • 627
  • 5
  • 26

1 Answers1

0
if(isset($data['content_module']))

Would be an alternative.

Hope this helps.

Niall Lonergan
  • 891
  • 1
  • 7
  • 29