On my set_positions foreach loop I load modules in side that foreach loop. I have two modules set at the moment.
But only one of them is showing for some reason should be another under it.
As shown here in image
![[Image: 3JU5XOtHqfFL.png]](https://ibin.co/3JU5XOtHqfFL.png)
The slide show module should show above the Question Help but as you can see below only one is showing in image
Question how can I make sure I can get all modules set for that position.
PHP Code:
public function index() {
$set_positions = $this->getlayoutpositions($this->router->class);
foreach ($set_positions as $set_position) {
$page_data['modules'] = array();
$modules = $this->getmodules($set_position['module_id']);
foreach ($modules as $module) {
$module_name = $module['module_name'];
$this->load->library('module/' . $module_name);
$page_data['modules'][] = $this->load->view('module/' . $module_name, $this->$module_name->get(), TRUE);
}
echo '<pre>';
print_r($modules);
echo '</pre>';
$data[$set_position['position']] = $this->load->view($set_position['position'], $page_data, TRUE);
}
$positions_not_set = $this->getpositions($set_positions);
foreach ($positions_not_set as $position_not_set) {
$page_data['modules'] = array();
$data[$position_not_set['position']] = $this->load->view($position_not_set['position'], $page_data, TRUE);
}
$this->load->view('welcome_message', $data);
}
Model functions
PHP Code:
public function getpositions($positions = array()) {
$this->db->select('*');
$this->db->from('positions');
foreach ($positions as $position) {
$this->db->where('position_id !=', $position['position_id']);
}
$query = $this->db->get();
return $query->result_array();
}
public function getlayoutpositions($page) {
$this->db->select('l.*, p.position');
$this->db->from('layouts l', 'LEFT');
$this->db->join('positions p', 'p.position_id = l.position_id', 'LEFT');
$this->db->where('page', $page);
//$this->db->group_by('l.position_id');
$query = $this->db->get();
return $query->result_array();
}
public function getmodules($module_id) {
$this->db->where('module_id', $module_id);
$this->db->order_by('sort_order', 'asc');
$query = $this->db->get('module');
return $query->result_array();
}
There's only one rule - please don't tell anyone to go and read the manual. Sometimes the manual just SUCKS!