Welcome Guest, Not a member yet? Register   Sign In
hmvc and pagination : how to ?
#1

[eluser]oll[/eluser]
Hi all and happy new year,

Here is my problem :
I have two controllers : one for playing a video and another one for displaying a playlist. (youtube like).
I want both controllers to display in the same page so I use hmvc for that :

My "super" controller looks like :

Code:
$data['player']= modules::run('player');
$data['playlist']= modules::run('pl');
$this->load->view('corps',$data);

And http://mysite displays both divs ('corps' view)

My playlist can be a bit long so I added the pagination library for displaying 5 videos, more precisely 5 thumbnails, per page. (something that looks like the right div "related videos" on youtube)

It works well alone :

http://mysite/pl displays the first 5 videos
http://mysite/pl/5 displays the 2nd page
http://mysite/pl/10 displays the 3rd page , etc...
and the pagination links update well.

here is the code in the pl.php controller :

Code:
<?php

class Pl extends Controller {

    function Pl()     {
        parent::Controller();
        $this->load->library('pagination');
                ...
        
    }
    
    function index($offset=1)    
        {
        ...
        //get all the results regarding user choice
        $playlist=$this->createplaylist ($choice);

        //now, let's paginate these results

        $nb_results = count($playlist);
            
        $config['base_url'] = base_url()."/pl/index";
        $config['total_rows'] = $nb_results;
        $config['per_page'] = '5';

        $this->pagination->initialize($config);

        $data['page']=$this->pagination->create_links();
        $partial_pl= $this->partial_pl($playlist,$offset);
        $data['videos']=$partial_pl;
            
        $this->load->view('playlist_view',$data);
        }
    }

    function partial_pl($playlist,$offset)
    {
        $length =  5;
        return array_slice($playlist,$offset,$length);
    }
}
?>


But I can't figure out how to make it work using hmvc ($data['playlist']= modules::run('pl')Wink since a click on a page number from the pagination displays obviously only the playlist controller, and not the "super" controller ?

Thanks.




Theme © iAndrew 2016 - Forum software by © MyBB