Welcome Guest, Not a member yet? Register   Sign In
Posting data to uri segent?
#1

[eluser]spyridonas[/eluser]
Is it possible? i have a search and the result url is "mysite/find" but i want the url to be "mysite/find/value" (where value whatever i put inside the input box) what i have so far is :
Code:
$route['shop/find/(:any)']= "shop/find/$1";
inside my routes , my find() function inside controller
Code:
function find($findV)
{
   $findV=$this->input->post('findSlug');
   $this->load->model('shopFront/find');
   $this->load->model('currency');
   $this->load->model('shopFront/calculate');
   $this->load->model('shop/proccess');
   $data = $this->commondatashop->general();
   $inputSlug = $this->input->post('findSlug');
   $data['tofind'] = $inputSlug;
   $data['cartInfo'] = $this->shopcart;
   $data['Currency'] = $this->currency;
   $data['Calculate'] = $this->calculate;
   $data['Proccess'] = $this->proccess;
   $data['title'] = "1.4.U Shop | Find";
   $finder = $this->find;
   $data['finderservice'] = $finder;
   $data['user_id'] = $this->session->userdata('user_id');
   $data['user_name'] = $this->session->userdata('user_name');
   $this->load->view('shop/top/topNew',$data);
   $this->load->view('shop/content/find',$data);
  
   //footer
   $curravailable = $this->calculate->getCurrencies();
   if ( $curravailable !== false )
   {
    $data['currencies'] = $curravailable;
   }
   else
   {
    $data['currencies'] = 'none';
   }
   $this->load->view('shop/footer',$data);
, the post part on the header , which is
Code:
<?php echo form_open('shop/find/','find'); ?>
    <input type="submit" name="find" value="" />
    <input type="text" name="findSlug" />
  <?php echo form_close();  ?>
this and finally the find.php which is the viewer. If i modify my viewer to search manually based on the 3rd segment then the search does happen , but i can't make the POST variable to go in the url
#2

[eluser]Ckirk[/eluser]
rather than using the form helper to create a form I'd use plain html and omit the action. That way your form would post as per the URI and would pick up $findV, without having to try and pass it as a hidden field

eg.
Code:
<form method="post" accept-charset="utf-8"  />

#3

[eluser]spyridonas[/eluser]
hmm with the simple form the results are the same , if i try to put the variable here
Code:
$this->load->view('shop/content/find',$data);
like
Code:
$this->load->view('shop/content/find/'.$inputSlug,$data);
it doesn't work
#4

[eluser]Ckirk[/eluser]
Now you've lost me.
Are you saying that you have multiple views with different names that match whatever is being passed in through findSlug?
Seems a bit uncontrolled
#5

[eluser]spyridonas[/eluser]
No i have one controller , one viewer its just that the text i write if i post it and get the data works fine , but the url is /find/find?=(text_here) , what i want is make it /find/(text_here) and i tried doing it by sending the variable (findSlug) on the view loading part (the logic was that the viewer will load with the value next to it , in this case , find/(my_text) ) If i modify my viewer to search the variable that's in the 3rd url segment it works fine , but i can't pass this 3rd segment simply by loading the viewer with it , or redirecting to this viewer, or if there's a way to pass the post or get variable to the uri cleanly. I think the solution is to grab the enter key with jquery and automaticly redirect to my url/find/input_value and done with it.. i mean there is no way that i can pass data to the url? a $data['url'] ? $this->url->setsegment ?




Theme © iAndrew 2016 - Forum software by © MyBB