blad Posted July 4, 2014 Posted July 4, 2014 Hello! My first post on the forum and I start with a question. I'm trying to modify the module datatable by Soma and I want to search by $page->id. code: if( $this->input->get->sSearch ) { $q = $this->sanitizer->text($this->input->get->sSearch); $selector .= "title|body%=$q,"; } my code (doesn´t work): if( $this->input->get->sSearch ) { $q = $this->sanitizer->text($this->input->get->sSearch); $selector .= "id|title|body%=$q,"; } $thanks->ryan; $thanks->soma; And please excuse my bad English
Macrura Posted July 4, 2014 Posted July 4, 2014 @blad - welcome to the forums! not totally sure here, but could possibly be an issue with trying to sanitize as text, since ID is (int). have you tried it without the sanitizer, and also have you tried it with different operators like *= and ~=?' 1
Soma Posted July 4, 2014 Posted July 4, 2014 Id is integer and not fulltext. You can't mix them with % but maybe with * . But you may need to have some additional logic to check if search is an Id or text. 1
blad Posted July 4, 2014 Author Posted July 4, 2014 Thanks @Macrura and thanks @Soma . I will try. Can i add an autonumeric field or a copy of id as text? My client want to search a number.
Wanze Posted July 4, 2014 Posted July 4, 2014 Hi Blad, You can do this with some additional logic: if( $this->input->get->sSearch ) { $q = $this->sanitizer->text($this->input->get->sSearch); if (is_numeric($q)) { $selector .= "id=$q,"; } else { $selector .= "title|body%=$q,"; } } 3
blad Posted July 4, 2014 Author Posted July 4, 2014 It works!! I love you @Wanze & i love processwire too !! 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now