• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Solved] inner foreach loop not displaying correct amount of modules

#1
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]
The slide show module should show above the Question Help but as you can see below only one is showing in image



[Image: 3JU6L2jhu34P.png]

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_dataTRUE);

}

$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_dataTRUE);
}


$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();



Attached Files
.php   Welcome.php (Size: 1.94 KB / Downloads: 93)
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply

#2
Stupid me I had 

$page_data['modules'] = array();

In wrong place
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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