url - Codeigniter load different site content foreach possible filter selection -
i have 2 input fields. in first filter user can select category, subcategory , in second filter user can choose product. upon submitting form, user gets redirected site based on selection in input fields.
$category = $this->input->post('category', true); $product = $this->input->post('product', true); if(isset($category) && $sub_category == ''){ redirect(base_url().'/category/'.$category); }elseif(isset($category) && isset($product)){ redirect(base_url().'/category/'.$category.'/product/'.$product); }else{ $this->session->set_flashdata('error', 'you must select category'); redirect($_server['http_referer']); }
creating urls , redirecting them based on user's input selection works fine. cannot head around how different view-content each site. each possible combination of category , product has own content. how can load individual content each possible url? hint!
try url
$category = $this->input->post('category', true); $product = $this->input->post('product', true); $url =array(); if($category){ $url[] = 'category/'.$category; } if($product){ $url[] ='product/'.$product; } $newurl = implode('/',$url); redirect($newurl);
Comments
Post a Comment