Welcome Guest, Not a member yet? Register   Sign In
Hebrew on URL?
#1

[eluser]LiorBroshi[/eluser]
Hola!

I am building a search function -> mysite.com/search/STRING_TO_SEARCH
and i've encountered two problems:

1. How can i create a form that the user enters string to search and it displays it in the URL? CI won't allow GET forms (because it creates questions marks...). i thought about JS form that just redirects to mysite.com/search/STRING_THAT_USER_TYPED_IN_TEXTBOX

2. How can I allow Hebrew chars on the URL? i dont know regexp stuff...


Lior
#2

[eluser]demogar[/eluser]
You could take a look at base64_encode and base64_decode

Do something like:
Code:
// Controller:

function form() {
  # load libraries (form_validation and form)
  if ( ! form_validation->run()) {
    $this->load->view('form');
  } else {
    $search = base64_encode($this->input->post("search"));
    redirect("search/" . $search);
  }
}

function search($string) {
  $string = base64_decode($string);
  # Work with the string. Use Zend Lucene for example.
}

The code is for you to take an idea about the code. You can use the base64_encode/decode in different ways. You could also make the form post to /do_search/ in do_search function encode the URL and then redirect to /search/ where you decode the URL and search the results and show them.

Cheers

Edit: If you will use this method I think you have to add some things to the URL permitted chars ( = ? for example). This is at your config.cfg file.

Regards
#3

[eluser]Shay Falador[/eluser]
Hey there, I am from Israel too Smile

About your first question, you should probably do one of the following:
a. Use javascript.
b. Receive by post and redirect (as demogar suggested).
About your second question, simply open APP-FOLDER/config/config.php, find: $config['permitted_uri_chars']. Add א-ת (the line should like this: $config['permitted_uri_chars'] = 'א-תa-z 0-9~%.:_-'Wink.

If you need any help feel free to contact me via msn or email <[email protected]>.
Good luck!




Theme © iAndrew 2016 - Forum software by © MyBB