CodeIgniter Forums
uri->segment_array() probelm - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: uri->segment_array() probelm (/thread-37005.html)



uri->segment_array() probelm - El Forum - 12-23-2010

[eluser]mikeymayhem[/eluser]
Hi there,

I recently discovered the uri->segement_array feature. I am having some trouble getting it working properly though. Maybe im thinking it should be doing stuff it cant. basically i have a page with multiple options to allow a user to refine a set of results. This means in need to allow key value pairs to be passed via the url which i will then use to refine my results, i was of the understanding that i would be able to define an array of defaults that would be used if the uri /key/value pair wasnt set and it wouldnt matter if some were not set or what order they were set in?

i have .htaccess removing index.php so the controller currently aiming to use this script is
home/ i have a route set up for this which is
Code:
$route['home/(:any)'] = 'home/index/$1';

then i want to be able to use pagination and pass params to functions from the array so my uri segments might look like this

home/num/5/offset/10/band/someband/venue/somevenue

then i might again look something like this

home/band/someband/venue/somevenue

am i missing something crucial here or does it just not work this way? should i be checking if those key value pairs are set in the array created by ruri->segment_array() ??

any help is greatly appreciated


here's a stripped down version of my controller
Code:
public function index()
    {
        //create an array for the default uri settings
        $defaults = array(
                            'num'    => 10,
                            'offset' => 0,
                            'table'  => 'gigs',
                            'column' => 'view',
                            'order'  => 'DESC'
                        );
        
        $params = $this->ruri->uri_to_assoc(3,$defaults);

        //pull all the gigs from database
        $gigs = $this->gig_model->get_gigs();
Thanks Mike


uri->segment_array() probelm - El Forum - 12-23-2010

[eluser]mikeymayhem[/eluser]
Hi i have just realised my major blunder! i was using the wrong uri function! Ignore me!! :S