Re: how to create search function.
Chetan, This is a awesome cake blog, congratulations. Nilson On Wed, Jun 6, 2012 at 4:08 AM, Chetan Patel wrote: > Hello Madhuri, > > Please check My blog: > > > http://chetan4cake.blogspot.in/2012/06/search-plugin-demo-in-cakephp-20.html > > Thanks > Chetan > > -- > Our newest site for the community: CakePHP Video Tutorials > http://tv.cakephp.org > Check out the new CakePHP Questions site http://ask.cakephp.org and help > others with their CakePHP related questions. > > > To unsubscribe from this group, send email to > cake-php+unsubscr...@googlegroups.com For more options, visit this group > at http://groups.google.com/group/cake-php > -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: how to create search function.
Hello Madhuri, Please check My blog: http://chetan4cake.blogspot.in/2012/06/search-plugin-demo-in-cakephp-20.html Thanks Chetan -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
how to create search function.
Hi, I'm new in using cakephp I'm wants to create a simple search function in my application which will search a particular word in table and will disply all records related to serch word. how i can create this search function. -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: adding a search function
try https://github.com/cakedc/search Am Dienstag, 22. Mai 2012 19:35:29 UTC+2 schrieb webguy262: > > How do I add a search function to an existing CakePHP site I inherited? -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
adding a search function
How do I add a search function to an existing CakePHP site I inherited? -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Is it possible to have more than one CakeDC search function in a controller / model ?
Is it possible to have more than one CakeDC search function in a controller / model? The reason I ask is because there is only one $filterArgs array in the model. -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Search Function in PHP Excel Reader - Error
What does this have to do with CakePHP? -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Search Function in PHP Excel Reader - Error
im using this php reader to retrieving data from xls sheet and its works well the xls sheet having 150 records. its limited to 20 records per page to show on result page .there is a search box and button to search some specific data , the search parameter giving the result from first page result only. i can't get result from full excel sheet. What is the expected output? What do you see instead? i need the reader to search whole xls sheet and give me result, but this one giving me from first 20 records only. Please provide any additional information below. i dont understan whats wrong here, y can't search full records on xls sheet. im expecting some ones help to solve my problem. plz see the attach file below for code thnxx.. $searchparameter=$_GET['searchparameter']; $startno=7; $totalrow=$data->rowcount($sheet_index=0); $rows=$i; if ($_GET['page']!="") $page=$_GET['page']; else $page=1; echo 'TABLE - $count=0; $recordno=1; for($i=0;$i<$totalrow-6;$i++) { //echo " searchparameter = ". $searchparameter ." data2 ". $data2 ; if((($page-1)*$rows)<=$i && $i<($page*$rows)) { //$data1=$data->val($startno+$i,1); $data2=$data->val($startno+$i,2); $data3=$data->val($startno+$i,3); $data4=$data->val($startno+$i,6); if((stristr($data2,$searchparameter) || stristr($data3,$searchparameter)|| stristr($data4,$searchparameter))|| $searchparameter=="") { echo 'TABLE } $recordno=$recordno+1; if($searchparameter=="") $count=$totalrow; $totalpage=$count/$rows; $totalpage=ceil($totalpage); for($i=1;$i<=$totalpage;$i++) { if ($i == $page) echo $i; -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: How to add "search" function in my e-commercial website?
try http://cakedc.com/downloads/view/cakephp_search_plugin On 7 Jul., 14:33, AddOil wrote: > Dear all, > > I'm a beginner of CakePHP. I created an e-commercial website based on > CakePHP. I'd like to add the "search" function to my website, which > allow users to search goods. > > Are there any functions or open source libraries that I can use in > CakePHP to do the "search" job? > > Thanks a lot! > > Qiang -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
How to add "search" function in my e-commercial website?
Dear all, I'm a beginner of CakePHP. I created an e-commercial website based on CakePHP. I'd like to add the "search" function to my website, which allow users to search goods. Are there any functions or open source libraries that I can use in CakePHP to do the "search" job? Thanks a lot! Qiang -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: search function results
On Thu, Mar 10, 2011 at 12:27 PM, chris...@yahoo.com wrote: > Thank you for your response Sam,... > In fact I did that,... another version to attempt... but now I'm not > getting search results, but the page is clean on URL bar,... and yes > its a urlencoded space %20 > > here is what I have... > > > function search($name = null) > { > if(!empty($this->data)) > { > $url = '/groups/search/'; > > if(!empty($this->data['Group']['name'])) > { > $url .= str_replace(' ', '+', $this->data['Group']['name']); > unset($this->data['Group']['name']); > } > > $this->redirect($url); > } > else > { > > $filter = $this->params['pass']; > unset($filter['page']); > unset($filter['sort']); > unset($filter['direction']); > $this->data = array('Group' => $filter); > $this->set('url_options', $filter); > > $this->data = array('Group' => array('name' => str_replace('+', > ' ', $name))); > > // $this->set_title(ucfirst(i18n::translate('search Groups'))); > $this- >>set_title(ucfirst(Inflector::pluralize(i18n::translate('group'))) . > ' : ' . str_replace('+', ' ', $name)); > > > $scope = array('Group.name IS NOT NULL'); > > foreach(array('name') as $field) > { > if(!empty($filter[$field])) > $scope[] = 'Group.' . $field . ' LIKE \'%' . > $filter[$field] . '%\''; > } > > if($this->is_user()) > $this->set('friends_ids', $this->Friend->myFriends($this- >>user['id'])); > else > $this->set('friends_ids', array()); > > if(empty($filter['name'])) > $this->set('groups', $this->paginate('Group', '1 = 0')); > else > $this->set('groups', $this->paginate('Group', $scope)); > > } > } > It's not clear to me how you're going about this. You have $name being passed to the method as a parameter, but you also have stuff in $this->params['pass']. Then, why are you unsetting things like $filter['page']? Also, you have: $this->data = array('Group' => $filter); Then, 2 lines later: $this->data = array('Group' => ... This makes no sense: foreach(array('name') as $field) If you're only using a single field, you don't need the foreach loop. As for the url encoding, simply use urldecode($name). You might also consider doing something along these lines: App::import('Sanitize'); $name = Sanitize::escape($name, 'default'); -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: search function results
Thank you for your response Sam,... In fact I did that,... another version to attempt... but now I'm not getting search results, but the page is clean on URL bar,... and yes its a urlencoded space %20 here is what I have... function search($name = null) { if(!empty($this->data)) { $url = '/groups/search/'; if(!empty($this->data['Group']['name'])) { $url .= str_replace(' ', '+', $this->data['Group']['name']); unset($this->data['Group']['name']); } $this->redirect($url); } else { $filter = $this->params['pass']; unset($filter['page']); unset($filter['sort']); unset($filter['direction']); $this->data = array('Group' => $filter); $this->set('url_options', $filter); $this->data = array('Group' => array('name' => str_replace('+', ' ', $name))); // $this->set_title(ucfirst(i18n::translate('search Groups'))); $this- >set_title(ucfirst(Inflector::pluralize(i18n::translate('group'))) . ' : ' . str_replace('+', ' ', $name)); $scope = array('Group.name IS NOT NULL'); foreach(array('name') as $field) { if(!empty($filter[$field])) $scope[] = 'Group.' . $field . ' LIKE \'%' . $filter[$field] . '%\''; } if($this->is_user()) $this->set('friends_ids', $this->Friend->myFriends($this- >user['id'])); else $this->set('friends_ids', array()); if(empty($filter['name'])) $this->set('groups', $this->paginate('Group', '1 = 0')); else $this->set('groups', $this->paginate('Group', $scope)); } } On Mar 10, 7:27 am, Sam Bernard wrote: > What error are you getting? %20 is just a urlencoded space... it isn't an > error. > > If you want to replace it with a space then just do your str_replace on your > $url var right before "$this->redirect($url);". -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: search function results
What error are you getting? %20 is just a urlencoded space... it isn't an error. If you want to replace it with a space then just do your str_replace on your $url var right before "$this->redirect($url);". -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
search function results
Hi ALL, can someone help me with "search" function... When I have 2 or more words in search field I'm getting en error on URL bar with %20 where I'm missing str_replace(' ', '+', and don't know where to put here is what I have in my controller ... function search() { $this->paginate['order'] = array('Group.created' => 'desc'); if(!empty($this->data)) { $url = '/groups/search/'; foreach($this->data['Group'] as $name => $value) { if(isset($value) && strlen($value) > 0) $url .= '/' . $name . ':' . $value; } $this->redirect($url); } else { $filter = $this->params['pass']; unset($filter['page']); unset($filter['sort']); unset($filter['direction']); $this->data = array('Group' => $filter); $this->set_title(ucfirst(i18n::translate('search Groups'))); $this->set('url_options', $filter); $scope = array('Group.name IS NOT NULL'); foreach(array('name') as $field) { if(!empty($filter[$field])) $scope[] = 'Group.' . $field . ' LIKE \'%' . $filter[$field] . '%\''; } if($this->is_user()) $this->set('friends_ids', $this->Friend->myFriends($this- >user['id'])); else $this->set('friends_ids', array()); if(empty($filter['name'])) $this->set('groups', $this->paginate('Group', '1 = 0')); else $this->set('groups', $this->paginate('Group', $scope)); } } -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Search function
> That should get you going. > > K @ Krissy, indeed it will. Thank you very much for taking the time. Much appreciated. I'll get stuck into this this evening :) -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
RE: Search function
To start I have it im app_model so I can use it anywhere. I think I said plugin last night but looks like I never ended up converting it into one. Delete the Cache::lines if you like for now: $alpha_links = array(); foreach(range('A','Z') as $i): $params = array( 'conditions' => array( $this->alias.'.search_group' => $i), 'fields' => array( $this->alias.'.title', $this->alias.'.id'), 'contain' => false); if ( $this->find('first', $params) ) { $alpha_links[$i] = 1; } else { $alpha_links[$i] = 0; } endforeach; return $alpha_links; Now since this is untested with the new array keys A, B, C my old helper for this has to be editied so untested off the top of my head: Controller call the function $this->set('alphabet', $this->Product->alpha_paging()); Helper: Just a function to run thru each $alphabet as $letter => $value { //make current link active if ( !empty ($this->params['pass']['0']) && $this->params['pass']['0'] === strtolower($letter)): $selected = "selected"; else:$selected = null; endif; $output .= $this->Html->link( $letter, array( 'action' => 'index', strtolower( $letter ), 'admin' => false) , array( 'escape' => false, 'class' => $selected ),false); else: $output .= $letter; That should get you going. K -Original Message- From: cake-php@googlegroups.com [mailto:cake-php@googlegroups.com] On Behalf Of MeatSandwich Sent: Friday, February 25, 2011 8:26 AM To: CakePHP Subject: Re: Search function Hi Krissy, that sounds absolutely perfect for the alphabet part of what I want to do, thank you :) Sorry for being such a noob but could you give me a bit more detail about how to use this code. Does that all go into the users_controller at the end of the add new user action? There are some things I don't recognise in the code which I guess must be something to do with the cache, so I'll have to go off and do a bit of reading! thanks On Feb 25, 9:10 am, "Krissy Masters" wrote: > For the Alphabet I made my own custom plugin function that just runs thru > the alphabet and does a query to find each letter. My table has search_group > field which saves the first letter upper / lowercase you decide of whatever > field the alphabet is for (name, business whatever) creates links if a > letter is found if not just a letter is returned. Cache the query so it only > runs 1 time and after a new user / member / product is added delete the > cache and update with a new running of the alpha function. > > public function alpha_paging () { > > $alpha_links = Cache::read('alpha_nav_'. $this->alias, 'short'); > > if (empty($alpha_links ) ) { > $alpha_links = array(); > > foreach(range('A','Z') as $i): > $params = array( > 'conditions' => array( > $this->alias.'.search_group' => $i), > 'fields' => array( > $this->alias.'.title', > $this->alias.'.id'), > 'contain' => false); > > if ( $this->find('first', $params) ) { > $alpha_links[] = 1; > } else { > $alpha_links[] = 0; > } > endforeach; > Cache::write( 'alpha_nav_'. $this->alias, $alpha_links, > 'short' ); > } > return $alpha_links; > > } > > You end up with an array 0 - 25 with each having a bool 0 or 1 if letter was > found. The array is numeric but that does not matter since we know how many > letters there are in the alphabet. > > 0 => 0 // A has no record > 1 => 0 // B has no record > 2 => 1 // C has a record > > ___ > Each array key represents the numeric count of the letter(offset by 1) > 0 => A > 1 => B &
RE: Search function
@euronark How do you mean? Interesting thought. How would you get 26 records each returning 1 search_field A-Z respectfully in 1 query? I was looking at the old code I found and posted last night and think another quick edit would be in the if: if ( $this->find('first', $params) ) { $alpha_links[$i] = 1; } else { $alpha_links[$i] = 0; } So you would end up with and real indexed array of letters rather than the 0 => 1 you should get A => 0, B => 0, C= 1. Not tested. @meat Will be around later this evening with free time and will dig up the rest of the function from the archive somewhere. K -Original Message- From: cake-php@googlegroups.com [mailto:cake-php@googlegroups.com] On Behalf Of euromark Sent: Friday, February 25, 2011 1:29 PM To: CakePHP Subject: Re: Search function @Krissy Masters instead of 25 single queries you could probably use a "group by" statement and a single query :) but nice idea, though On 25 Feb., 15:43, MeatSandwich wrote: > Hey acl68, thanks for that, definitely does point me in the right > direction. I need to go off and brush up a bit on my javascript but > hopefully what you've given me will do the job. > > thanks > > On Feb 25, 1:58 pm, acl68 wrote: > > > > > > > > > Hi Sandwich, > > > I did something simliar like you want to do with the checkboxes with a drop- > > down list. I didn't use the searchable-behaviour-for-cakephp but used AJAX > > instead. > > > On top of my search from ctp I includ a JavaScript file: > > > > > In my search form I have my dropdown: > > echo $this->Form->input('category_id', array('onChange' => > > 'getFoodByCategory()', 'empty' => '---')); > > > foodselect.js: > > > function getFoodByCategory() { > > var category_id = document.getElementById('UserpointCategoryId').value; > > // alert(category_id); > > > // alert('/ww/foods/getFoodByCategory/' + category_id); > > $.post('/ww/foods/getFoodByCategory/' + category_id, function(data) { > > document.getElementById('UserpointFoodIdDiv').innerHTML = data; > > }); > > > } > > > in my foods controller I have the function: > > > function getFoodByCategory($category_id = null) { > > $this->layout='ajax'; > > $this->Food->recursive = 0; > > $this->Food->order = array('Food.name asc'); > > $param = array( 'conditions' => array('Food.category_id' => > > $category_id)); $foodall = $this->Food->find('all',$param); > > foreach ($foodall as $food){ > > $li[$food['Food']['id']] = $food['Food']['name'].' ('. > > $food['Food']['points'].' Punkte)'; > > } > > > $this->set('foods',$li); > > } > > > This together fills my another dropdown with my food selection, but you can > > also have a div filles with an index table, depending what you want. > > > the output is formatted in the file /views/foods/get_food_by_category.ctp > > In my case it creates the dropdown: > > > //debug($foods); > > > echo ''; > > > foreach($foods as $key => $value){ > > echo utf8_decode ( ''.$value.'');} > > > echo ''; > > ?> > > > In Javascript a dropdown is easier to handle than checkboxes, as you might > > know, but they should also work. > > > Hoep that example helps > > > Anja > > > Am Donnerstag, 24. Februar 2011, um 20:13:03 schrieb MeatSandwich: > > > > Hi all, > > > > I'm new to cakephp and only know a bit of php so I'm on a steep > > > learning curve since although I've made websites using php and mysql > > > before they were all a bit simple. I'm not looking for code here but > > > some pointers for me so I know what to learn. > > > > The app I'm making will end up with lots of members and I'd like to > > > make a search function so people can find other people easily. I've > > > discovered searchable-behaviour-for-cakephp and hopefully that'll > > > provide most of what I want but as anoth
Re: Search function
@Krissy Masters instead of 25 single queries you could probably use a "group by" statement and a single query :) but nice idea, though On 25 Feb., 15:43, MeatSandwich wrote: > Hey acl68, thanks for that, definitely does point me in the right > direction. I need to go off and brush up a bit on my javascript but > hopefully what you've given me will do the job. > > thanks > > On Feb 25, 1:58 pm, acl68 wrote: > > > > > > > > > Hi Sandwich, > > > I did something simliar like you want to do with the checkboxes with a drop- > > down list. I didn't use the searchable-behaviour-for-cakephp but used AJAX > > instead. > > > On top of my search from ctp I includ a JavaScript file: > > > > > In my search form I have my dropdown: > > echo $this->Form->input('category_id', array('onChange' => > > 'getFoodByCategory()', 'empty' => '---')); > > > foodselect.js: > > > function getFoodByCategory() { > > var category_id = > > document.getElementById('UserpointCategoryId').value; > > // alert(category_id); > > > // alert('/ww/foods/getFoodByCategory/' + category_id); > > $.post('/ww/foods/getFoodByCategory/' + category_id, function(data) > > { > > > > document.getElementById('UserpointFoodIdDiv').innerHTML = data; > > }); > > > } > > > in my foods controller I have the function: > > > function getFoodByCategory($category_id = null) { > > $this->layout='ajax'; > > $this->Food->recursive = 0; > > $this->Food->order = array('Food.name asc'); > > $param = array( 'conditions' => array('Food.category_id' => > > $category_id)); $foodall = $this->Food->find('all',$param); > > foreach ($foodall as $food){ > > $li[$food['Food']['id']] = $food['Food']['name'].' > > ('. > > $food['Food']['points'].' Punkte)'; > > } > > > $this->set('foods',$li); > > } > > > This together fills my another dropdown with my food selection, but you can > > also have a div filles with an index table, depending what you want. > > > the output is formatted in the file /views/foods/get_food_by_category.ctp > > In my case it creates the dropdown: > > > //debug($foods); > > > echo ''; > > > foreach($foods as $key => $value){ > > echo utf8_decode ( ''.$value.'');} > > > echo ''; > > ?> > > > In Javascript a dropdown is easier to handle than checkboxes, as you might > > know, but they should also work. > > > Hoep that example helps > > > Anja > > > Am Donnerstag, 24. Februar 2011, um 20:13:03 schrieb MeatSandwich: > > > > Hi all, > > > > I'm new to cakephp and only know a bit of php so I'm on a steep > > > learning curve since although I've made websites using php and mysql > > > before they were all a bit simple. I'm not looking for code here but > > > some pointers for me so I know what to learn. > > > > The app I'm making will end up with lots of members and I'd like to > > > make a search function so people can find other people easily. I've > > > discovered searchable-behaviour-for-cakephp and hopefully that'll > > > provide most of what I want but as another way to search rather than a > > > text box, I'd also like to have the letters of the alphabet so a user > > > can click and go straight to that letter. > > > > As well as that, members will say in their profiles what their > > > favourite animals are, ie cats/dogs/horses etc - they'll have 20 to > > > choose from. I'd like my search function to have checkboxes > > > representing each animal and someone who was searching could check the > > > dogs box and only people who like dogs will be listed, they could then > > > also check cats box and the members who like dogs and cats will be > > > shown. If possible I'd like the list to update automatically as each > > > box is clicked. > > > > I have everything else set up and only need help with this search > > > part. Assuming searchable-behaviour-for-cakephp does me for my text > > > search box, I reckon the alphabet thing will be something like making > > > a link for each letter and somehow making that link run a query, > > > hopefully that will work. > > > > But the checkbox thing that updates automatically I'm not sure about. > > > Is it ajax I need? Are there any particular methods I should be using? -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Search function
Hey acl68, thanks for that, definitely does point me in the right direction. I need to go off and brush up a bit on my javascript but hopefully what you've given me will do the job. thanks On Feb 25, 1:58 pm, acl68 wrote: > Hi Sandwich, > > I did something simliar like you want to do with the checkboxes with a drop- > down list. I didn't use the searchable-behaviour-for-cakephp but used AJAX > instead. > > On top of my search from ctp I includ a JavaScript file: > > > In my search form I have my dropdown: > echo $this->Form->input('category_id', array('onChange' => > 'getFoodByCategory()', 'empty' => '---')); > > foodselect.js: > > function getFoodByCategory() { > var category_id = > document.getElementById('UserpointCategoryId').value; > // alert(category_id); > > // alert('/ww/foods/getFoodByCategory/' + category_id); > $.post('/ww/foods/getFoodByCategory/' + category_id, function(data) { > > document.getElementById('UserpointFoodIdDiv').innerHTML = data; > }); > > } > > in my foods controller I have the function: > > function getFoodByCategory($category_id = null) { > $this->layout='ajax'; > $this->Food->recursive = 0; > $this->Food->order = array('Food.name asc'); > $param = array( 'conditions' => array('Food.category_id' => > $category_id)); $foodall = $this->Food->find('all',$param); > foreach ($foodall as $food){ > $li[$food['Food']['id']] = $food['Food']['name'].' ('. > $food['Food']['points'].' Punkte)'; > } > > $this->set('foods',$li); > } > > This together fills my another dropdown with my food selection, but you can > also have a div filles with an index table, depending what you want. > > the output is formatted in the file /views/foods/get_food_by_category.ctp > In my case it creates the dropdown: > //debug($foods); > > echo ''; > > foreach($foods as $key => $value){ > echo utf8_decode ( ''.$value.'');} > > echo ''; > ?> > > In Javascript a dropdown is easier to handle than checkboxes, as you might > know, but they should also work. > > Hoep that example helps > > Anja > > Am Donnerstag, 24. Februar 2011, um 20:13:03 schrieb MeatSandwich: > > > Hi all, > > > I'm new to cakephp and only know a bit of php so I'm on a steep > > learning curve since although I've made websites using php and mysql > > before they were all a bit simple. I'm not looking for code here but > > some pointers for me so I know what to learn. > > > The app I'm making will end up with lots of members and I'd like to > > make a search function so people can find other people easily. I've > > discovered searchable-behaviour-for-cakephp and hopefully that'll > > provide most of what I want but as another way to search rather than a > > text box, I'd also like to have the letters of the alphabet so a user > > can click and go straight to that letter. > > > As well as that, members will say in their profiles what their > > favourite animals are, ie cats/dogs/horses etc - they'll have 20 to > > choose from. I'd like my search function to have checkboxes > > representing each animal and someone who was searching could check the > > dogs box and only people who like dogs will be listed, they could then > > also check cats box and the members who like dogs and cats will be > > shown. If possible I'd like the list to update automatically as each > > box is clicked. > > > I have everything else set up and only need help with this search > > part. Assuming searchable-behaviour-for-cakephp does me for my text > > search box, I reckon the alphabet thing will be something like making > > a link for each letter and somehow making that link run a query, > > hopefully that will work. > > > But the checkbox thing that updates automatically I'm not sure about. > > Is it ajax I need? Are there any particular methods I should be using? -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Search function
Hi Sandwich, I did something simliar like you want to do with the checkboxes with a drop- down list. I didn't use the searchable-behaviour-for-cakephp but used AJAX instead. On top of my search from ctp I includ a JavaScript file: In my search form I have my dropdown: echo $this->Form->input('category_id', array('onChange' => 'getFoodByCategory()', 'empty' => '---')); foodselect.js: function getFoodByCategory() { var category_id = document.getElementById('UserpointCategoryId').value; // alert(category_id); // alert('/ww/foods/getFoodByCategory/' + category_id); $.post('/ww/foods/getFoodByCategory/' + category_id, function(data) { document.getElementById('UserpointFoodIdDiv').innerHTML = data; }); } in my foods controller I have the function: function getFoodByCategory($category_id = null) { $this->layout='ajax'; $this->Food->recursive = 0; $this->Food->order = array('Food.name asc'); $param = array( 'conditions' => array('Food.category_id' => $category_id)); $foodall = $this->Food->find('all',$param); foreach ($foodall as $food){ $li[$food['Food']['id']] = $food['Food']['name'].' ('. $food['Food']['points'].' Punkte)'; } $this->set('foods',$li); } This together fills my another dropdown with my food selection, but you can also have a div filles with an index table, depending what you want. the output is formatted in the file /views/foods/get_food_by_category.ctp In my case it creates the dropdown: '; foreach($foods as $key => $value){ echo utf8_decode ( ''.$value.''); } echo ''; ?> In Javascript a dropdown is easier to handle than checkboxes, as you might know, but they should also work. Hoep that example helps Anja Am Donnerstag, 24. Februar 2011, um 20:13:03 schrieb MeatSandwich: > Hi all, > > I'm new to cakephp and only know a bit of php so I'm on a steep > learning curve since although I've made websites using php and mysql > before they were all a bit simple. I'm not looking for code here but > some pointers for me so I know what to learn. > > The app I'm making will end up with lots of members and I'd like to > make a search function so people can find other people easily. I've > discovered searchable-behaviour-for-cakephp and hopefully that'll > provide most of what I want but as another way to search rather than a > text box, I'd also like to have the letters of the alphabet so a user > can click and go straight to that letter. > > As well as that, members will say in their profiles what their > favourite animals are, ie cats/dogs/horses etc - they'll have 20 to > choose from. I'd like my search function to have checkboxes > representing each animal and someone who was searching could check the > dogs box and only people who like dogs will be listed, they could then > also check cats box and the members who like dogs and cats will be > shown. If possible I'd like the list to update automatically as each > box is clicked. > > I have everything else set up and only need help with this search > part. Assuming searchable-behaviour-for-cakephp does me for my text > search box, I reckon the alphabet thing will be something like making > a link for each letter and somehow making that link run a query, > hopefully that will work. > > But the checkbox thing that updates automatically I'm not sure about. > Is it ajax I need? Are there any particular methods I should be using? -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Search function
Hi Krissy, that sounds absolutely perfect for the alphabet part of what I want to do, thank you :) Sorry for being such a noob but could you give me a bit more detail about how to use this code. Does that all go into the users_controller at the end of the add new user action? There are some things I don't recognise in the code which I guess must be something to do with the cache, so I'll have to go off and do a bit of reading! thanks On Feb 25, 9:10 am, "Krissy Masters" wrote: > For the Alphabet I made my own custom plugin function that just runs thru > the alphabet and does a query to find each letter. My table has search_group > field which saves the first letter upper / lowercase you decide of whatever > field the alphabet is for (name, business whatever) creates links if a > letter is found if not just a letter is returned. Cache the query so it only > runs 1 time and after a new user / member / product is added delete the > cache and update with a new running of the alpha function. > > public function alpha_paging () { > > $alpha_links = Cache::read('alpha_nav_'. $this->alias, 'short'); > > if (empty($alpha_links ) ) { > $alpha_links = array(); > > foreach(range('A','Z') as $i): > $params = array( > 'conditions' => array( > $this->alias.'.search_group' => $i), > 'fields' => array( > $this->alias.'.title', > $this->alias.'.id'), > 'contain' => false); > > if ( $this->find('first', $params) ) { > $alpha_links[] = 1; > } else { > $alpha_links[] = 0; > } > endforeach; > Cache::write( 'alpha_nav_'. $this->alias, $alpha_links, > 'short' ); > } > return $alpha_links; > > } > > You end up with an array 0 - 25 with each having a bool 0 or 1 if letter was > found. The array is numeric but that does not matter since we know how many > letters there are in the alphabet. > > 0 => 0 // A has no record > 1 => 0 // B has no record > 2 => 1 // C has a record > > ___ > Each array key represents the numeric count of the letter(offset by 1) > 0 => A > 1 => B > > 25 => Z > > Hope that gets you started. > > K > > -Original Message- > From: cake-php@googlegroups.com [mailto:cake-php@googlegroups.com] On Behalf > > Of MeatSandwich > Sent: Thursday, February 24, 2011 3:43 PM > To: CakePHP > Subject: Search function > > Hi all, > > I'm new to cakephp and only know a bit of php so I'm on a steep > learning curve since although I've made websites using php and mysql > before they were all a bit simple. I'm not looking for code here but > some pointers for me so I know what to learn. > > The app I'm making will end up with lots of members and I'd like to > make a search function so people can find other people easily. I've > discovered searchable-behaviour-for-cakephp and hopefully that'll > provide most of what I want but as another way to search rather than a > text box, I'd also like to have the letters of the alphabet so a user > can click and go straight to that letter. > > As well as that, members will say in their profiles what their > favourite animals are, ie cats/dogs/horses etc - they'll have 20 to > choose from. I'd like my search function to have checkboxes > representing each animal and someone who was searching could check the > dogs box and only people who like dogs will be listed, they could then > also check cats box and the members who like dogs and cats will be > shown. If possible I'd like the list to update automatically as each > box is clicked. > > I have everything else set up and only need help with this search > part. Assuming searchable-behaviour-for-cakephp does me for my text > search box, I reckon the alphabet thing will be something like making > a link for each letter and somehow making that link run a query, > hopefully that will work. > > But the checkbox thing that updates automatically I'm not sure about. > Is it ajax I need? Are there any particular methods I should be using? > > -- > Our newest
RE: Search function
For the Alphabet I made my own custom plugin function that just runs thru the alphabet and does a query to find each letter. My table has search_group field which saves the first letter upper / lowercase you decide of whatever field the alphabet is for (name, business whatever) creates links if a letter is found if not just a letter is returned. Cache the query so it only runs 1 time and after a new user / member / product is added delete the cache and update with a new running of the alpha function. public function alpha_paging () { $alpha_links = Cache::read('alpha_nav_'. $this->alias, 'short'); if (empty($alpha_links ) ) { $alpha_links = array(); foreach(range('A','Z') as $i): $params = array( 'conditions' => array( $this->alias.'.search_group' => $i), 'fields' => array( $this->alias.'.title', $this->alias.'.id'), 'contain' => false); if ( $this->find('first', $params) ) { $alpha_links[] = 1; } else { $alpha_links[] = 0; } endforeach; Cache::write( 'alpha_nav_'. $this->alias, $alpha_links, 'short' ); } return $alpha_links; } You end up with an array 0 - 25 with each having a bool 0 or 1 if letter was found. The array is numeric but that does not matter since we know how many letters there are in the alphabet. 0 => 0 // A has no record 1 => 0 // B has no record 2 => 1 // C has a record ___ Each array key represents the numeric count of the letter(offset by 1) 0 => A 1 => B 25 => Z Hope that gets you started. K -Original Message- From: cake-php@googlegroups.com [mailto:cake-php@googlegroups.com] On Behalf Of MeatSandwich Sent: Thursday, February 24, 2011 3:43 PM To: CakePHP Subject: Search function Hi all, I'm new to cakephp and only know a bit of php so I'm on a steep learning curve since although I've made websites using php and mysql before they were all a bit simple. I'm not looking for code here but some pointers for me so I know what to learn. The app I'm making will end up with lots of members and I'd like to make a search function so people can find other people easily. I've discovered searchable-behaviour-for-cakephp and hopefully that'll provide most of what I want but as another way to search rather than a text box, I'd also like to have the letters of the alphabet so a user can click and go straight to that letter. As well as that, members will say in their profiles what their favourite animals are, ie cats/dogs/horses etc - they'll have 20 to choose from. I'd like my search function to have checkboxes representing each animal and someone who was searching could check the dogs box and only people who like dogs will be listed, they could then also check cats box and the members who like dogs and cats will be shown. If possible I'd like the list to update automatically as each box is clicked. I have everything else set up and only need help with this search part. Assuming searchable-behaviour-for-cakephp does me for my text search box, I reckon the alphabet thing will be something like making a link for each letter and somehow making that link run a query, hopefully that will work. But the checkbox thing that updates automatically I'm not sure about. Is it ajax I need? Are there any particular methods I should be using? -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Search function
Hi all, I'm new to cakephp and only know a bit of php so I'm on a steep learning curve since although I've made websites using php and mysql before they were all a bit simple. I'm not looking for code here but some pointers for me so I know what to learn. The app I'm making will end up with lots of members and I'd like to make a search function so people can find other people easily. I've discovered searchable-behaviour-for-cakephp and hopefully that'll provide most of what I want but as another way to search rather than a text box, I'd also like to have the letters of the alphabet so a user can click and go straight to that letter. As well as that, members will say in their profiles what their favourite animals are, ie cats/dogs/horses etc - they'll have 20 to choose from. I'd like my search function to have checkboxes representing each animal and someone who was searching could check the dogs box and only people who like dogs will be listed, they could then also check cats box and the members who like dogs and cats will be shown. If possible I'd like the list to update automatically as each box is clicked. I have everything else set up and only need help with this search part. Assuming searchable-behaviour-for-cakephp does me for my text search box, I reckon the alphabet thing will be something like making a link for each letter and somehow making that link run a query, hopefully that will work. But the checkbox thing that updates automatically I'm not sure about. Is it ajax I need? Are there any particular methods I should be using? -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
RE: Search function
Good point! Will look into it, but when I do a search now if I type in Mary or mary I get the same results. What would you suggest? Dave -Original Message- From: John Andersen [mailto:j.andersen...@gmail.com] Sent: August-14-09 2:45 AM To: CakePHP Subject: Re: Search function Hi Dave, Congratulations on the job done! Only one small issue/question, do you take into account, that words may be in uppercase/lowercase? Enjoy, John On Aug 13, 11:02 pm, "Dave Maharaj :: WidePixels.com" wrote: > This is what I ended up with and works. > > function __quickQuery($string, $rank, $auth) > { > > //create an array of search terms if more than 1 was > entered > $string = split(",", $string); > > $i=0; // This is each counter > // Now build your SQL String > $sql = ""; > foreach ($string as $key => $value) > { > $value = trim($value); > //strip white space befor and after each term > $sql.= "Post.title LIKE '%" . $value . "%' OR > Post.description LIKE '%" . $value . "%'"; > $i++; // Put your counter up by 1 > if($i < count($string)) // Check if your > counter is smaller than amount of values in array, if there are still > values, add a OR > { > $sql.=" OR "; > } > } > > $params = array( > 'conditions' > => array('Post.status' => 0 , 'Post.rank <=' => $rank, $sql), > > So on and on > ))); > > $q = $this->find('all', $params); > > return $q; > > } > > Pass the $sql to the conditions and I end up with Post.title LIKE > '%mary%' OR Post.description LIKE '%mary%' OR Post.title LIKE '%test%' > OR Post.description LIKE '%test%' OR Post.title LIKE '%something%' OR > Post.description LIKE '%something%' > > -Original Message- > From: Luke [mailto:eik...@hotmail.com] > Sent: August-12-09 1:45 PM > To: CakePHP > Subject: Re: Search function > > You are missing a few OR in your below text, I have tried it out and > get all the needed OR, did you just keft it out below or what is the issue? > Oh and by the way of course you will need a WHERE aswell in the first > part $sql = "SELECT * FROM table"; I forgot that one. > > On 12 Aug., 17:00, "Dave Maharaj :: WidePixels.com" > wrote: > > Yeah that's the basic idea to build the "Post.title LIKE '%" . $value. > "%' > > OR Post.description LIKE '%" . $value . "%' "; string from the user > > submitted text > > > So if there are 3 words it ends up "Post.title LIKE '%" . $value. "%' > > OR Post.description LIKE '%" . $value . "%' ";"Post.title LIKE '%" . > $value. > > "%' OR Post.description LIKE '%" . $value . "%' ";"Post.title LIKE '%" . > > $value. "%' OR Post.description LIKE '%" . $value . "%' "; > > > -Original Message- > > From: Luke [mailto:eik...@hotmail.com] > > Sent: August-12-09 11:43 AM > > To: CakePHP > > Subject: Re: Search function > > > Hi Dave, > > > Maybe not the nicest solution, but this should work: > > > $i=0; // This is your counter > > > // Now build your SQL String > > $sql = "SELECT * FROM table"; > > > foreach ($string as $key => $value) > > { $value = trim($value); > > > //strip white space befor and after each > > term > > // $value = trim($string[$i]); > > $sql.= "Post.title LIKE '%" . $value. "%' > > OR Post.description LIKE '%" . $value . "%' "; > > > $i++; // Put your counter up by 1 > > if($i < count($string)) // Check if your counter is smaller > > than amount of values in array, if there are still values, add a OR > > { > > $sql.="OR"; > > } > > } > > > You can try out by putting in echo $sql at the end. > > > Is this what you were looking for or did I missunderstood? > > > Luke- Zitierten Text ausblenden - > > > - Zitierten Text anzeigen - --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Search function
Hi Dave, Congratulations on the job done! Only one small issue/question, do you take into account, that words may be in uppercase/lowercase? Enjoy, John On Aug 13, 11:02 pm, "Dave Maharaj :: WidePixels.com" wrote: > This is what I ended up with and works. > > function __quickQuery($string, $rank, $auth) > { > > //create an array of search terms if more than 1 was > entered > $string = split(",", $string); > > $i=0; // This is each counter > // Now build your SQL String > $sql = ""; > foreach ($string as $key => $value) > { > $value = trim($value); > //strip white space befor and after each term > $sql.= "Post.title LIKE '%" . $value . "%' OR > Post.description LIKE '%" . $value . "%'"; > $i++; // Put your counter up by 1 > if($i < count($string)) // Check if your counter is > smaller than amount of values in array, if there are still values, add a OR > { > $sql.=" OR "; > } > } > > $params = array( > 'conditions' => > array('Post.status' => 0 , 'Post.rank <=' => $rank, $sql), > So on > and on > ))); > > $q = $this->find('all', $params); > > return $q; > > } > > Pass the $sql to the conditions and I end up with > Post.title LIKE '%mary%' OR Post.description LIKE '%mary%' OR Post.title > LIKE '%test%' OR Post.description LIKE '%test%' OR Post.title LIKE > '%something%' OR Post.description LIKE '%something%' > > -Original Message- > From: Luke [mailto:eik...@hotmail.com] > Sent: August-12-09 1:45 PM > To: CakePHP > Subject: Re: Search function > > You are missing a few OR in your below text, I have tried it out and get all > the needed OR, did you just keft it out below or what is the issue? > Oh and by the way of course you will need a WHERE aswell in the first part > $sql = "SELECT * FROM table"; I forgot that one. > > On 12 Aug., 17:00, "Dave Maharaj :: WidePixels.com" > wrote: > > Yeah that's the basic idea to build the "Post.title LIKE '%" . $value. > "%' > > OR Post.description LIKE '%" . $value . "%' "; string from the user > > submitted text > > > So if there are 3 words it ends up "Post.title LIKE '%" . $value. "%' > > OR Post.description LIKE '%" . $value . "%' ";"Post.title LIKE '%" . > $value. > > "%' OR Post.description LIKE '%" . $value . "%' ";"Post.title LIKE '%" . > > $value. "%' OR Post.description LIKE '%" . $value . "%' "; > > > -Original Message- > > From: Luke [mailto:eik...@hotmail.com] > > Sent: August-12-09 11:43 AM > > To: CakePHP > > Subject: Re: Search function > > > Hi Dave, > > > Maybe not the nicest solution, but this should work: > > > $i=0; // This is your counter > > > // Now build your SQL String > > $sql = "SELECT * FROM table"; > > > foreach ($string as $key => $value) > > { $value = trim($value); > > > //strip white space befor and after each term > > // $value = trim($string[$i]); > > $sql.= "Post.title LIKE '%" . $value. "%' OR > > Post.description LIKE '%" . $value . "%' "; > > > $i++; // Put your counter up by 1 > > if($i < count($string)) // Check if your counter is smaller than > > amount of values in array, if there are still values, add a OR > > { > > $sql.="OR"; > > } > > } > > > You can try out by putting in echo $sql at the end. > > > Is this what you were looking for or did I missunderstood? > > > Luke- Zitierten Text ausblenden - > > > - Zitierten Text anzeigen - --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
RE: Search function
This is what I ended up with and works. function __quickQuery($string, $rank, $auth) { //create an array of search terms if more than 1 was entered $string = split(",", $string); $i=0; // This is each counter // Now build your SQL String $sql = ""; foreach ($string as $key => $value) { $value = trim($value); //strip white space befor and after each term $sql.= "Post.title LIKE '%" . $value . "%' OR Post.description LIKE '%" . $value . "%'"; $i++; // Put your counter up by 1 if($i < count($string)) // Check if your counter is smaller than amount of values in array, if there are still values, add a OR { $sql.=" OR "; } } $params = array( 'conditions' => array('Post.status' => 0 , 'Post.rank <=' => $rank, $sql), So on and on ))); $q = $this->find('all', $params); return $q; } Pass the $sql to the conditions and I end up with Post.title LIKE '%mary%' OR Post.description LIKE '%mary%' OR Post.title LIKE '%test%' OR Post.description LIKE '%test%' OR Post.title LIKE '%something%' OR Post.description LIKE '%something%' -Original Message- From: Luke [mailto:eik...@hotmail.com] Sent: August-12-09 1:45 PM To: CakePHP Subject: Re: Search function You are missing a few OR in your below text, I have tried it out and get all the needed OR, did you just keft it out below or what is the issue? Oh and by the way of course you will need a WHERE aswell in the first part $sql = "SELECT * FROM table"; I forgot that one. On 12 Aug., 17:00, "Dave Maharaj :: WidePixels.com" wrote: > Yeah that's the basic idea to build the "Post.title LIKE '%" . $value. "%' > OR Post.description LIKE '%" . $value . "%' "; string from the user > submitted text > > So if there are 3 words it ends up "Post.title LIKE '%" . $value. "%' > OR Post.description LIKE '%" . $value . "%' ";"Post.title LIKE '%" . $value. > "%' OR Post.description LIKE '%" . $value . "%' ";"Post.title LIKE '%" . > $value. "%' OR Post.description LIKE '%" . $value . "%' "; > > > > -Original Message- > From: Luke [mailto:eik...@hotmail.com] > Sent: August-12-09 11:43 AM > To: CakePHP > Subject: Re: Search function > > Hi Dave, > > Maybe not the nicest solution, but this should work: > > $i=0; // This is your counter > > // Now build your SQL String > $sql = "SELECT * FROM table"; > > foreach ($string as $key => $value) > { $value = trim($value); > > //strip white space befor and after each term > // $value = trim($string[$i]); > $sql.= "Post.title LIKE '%" . $value. "%' OR > Post.description LIKE '%" . $value . "%' "; > > $i++; // Put your counter up by 1 > if($i < count($string)) // Check if your counter is smaller than > amount of values in array, if there are still values, add a OR > { > $sql.="OR"; > } > } > > You can try out by putting in echo $sql at the end. > > Is this what you were looking for or did I missunderstood? > > Luke- Zitierten Text ausblenden - > > - Zitierten Text anzeigen - --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Search function
You are missing a few OR in your below text, I have tried it out and get all the needed OR, did you just keft it out below or what is the issue? Oh and by the way of course you will need a WHERE aswell in the first part $sql = "SELECT * FROM table"; I forgot that one. On 12 Aug., 17:00, "Dave Maharaj :: WidePixels.com" wrote: > Yeah that's the basic idea to build the "Post.title LIKE '%" . $value. "%' > OR Post.description LIKE '%" . $value . "%' "; string from the user > submitted text > > So if there are 3 words it ends up "Post.title LIKE '%" . $value. "%' OR > Post.description LIKE '%" . $value . "%' ";"Post.title LIKE '%" . $value. > "%' OR Post.description LIKE '%" . $value . "%' ";"Post.title LIKE '%" . > $value. "%' OR Post.description LIKE '%" . $value . "%' "; > > > > -Original Message- > From: Luke [mailto:eik...@hotmail.com] > Sent: August-12-09 11:43 AM > To: CakePHP > Subject: Re: Search function > > Hi Dave, > > Maybe not the nicest solution, but this should work: > > $i=0; // This is your counter > > // Now build your SQL String > $sql = "SELECT * FROM table"; > > foreach ($string as $key => $value) > { $value = trim($value); > > //strip white space befor and after each term > // $value = trim($string[$i]); > $sql.= "Post.title LIKE '%" . $value. "%' OR > Post.description LIKE '%" . $value . "%' "; > > $i++; // Put your counter up by 1 > if($i < count($string)) // Check if your counter is smaller than > amount of values in array, if there are still values, add a OR > { > $sql.="OR"; > } > } > > You can try out by putting in echo $sql at the end. > > Is this what you were looking for or did I missunderstood? > > Luke- Zitierten Text ausblenden - > > - Zitierten Text anzeigen - --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
RE: Search function
Yeah that's the basic idea to build the "Post.title LIKE '%" . $value. "%' OR Post.description LIKE '%" . $value . "%' "; string from the user submitted text So if there are 3 words it ends up "Post.title LIKE '%" . $value. "%' OR Post.description LIKE '%" . $value . "%' ";"Post.title LIKE '%" . $value. "%' OR Post.description LIKE '%" . $value . "%' ";"Post.title LIKE '%" . $value. "%' OR Post.description LIKE '%" . $value . "%' "; -Original Message- From: Luke [mailto:eik...@hotmail.com] Sent: August-12-09 11:43 AM To: CakePHP Subject: Re: Search function Hi Dave, Maybe not the nicest solution, but this should work: $i=0; // This is your counter // Now build your SQL String $sql = "SELECT * FROM table"; foreach ($string as $key => $value) { $value = trim($value); //strip white space befor and after each term // $value = trim($string[$i]); $sql.= "Post.title LIKE '%" . $value. "%' OR Post.description LIKE '%" . $value . "%' "; $i++; // Put your counter up by 1 if($i < count($string)) // Check if your counter is smaller than amount of values in array, if there are still values, add a OR { $sql.="OR"; } } You can try out by putting in echo $sql at the end. Is this what you were looking for or did I missunderstood? Luke --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Search function
Hi Dave, Maybe not the nicest solution, but this should work: $i=0; // This is your counter // Now build your SQL String $sql = "SELECT * FROM table"; foreach ($string as $key => $value) { $value = trim($value); //strip white space befor and after each term // $value = trim($string[$i]); $sql.= "Post.title LIKE '%" . $value. "%' OR Post.description LIKE '%" . $value . "%' "; $i++; // Put your counter up by 1 if($i < count($string)) // Check if your counter is smaller than amount of values in array, if there are still values, add a OR { $sql.="OR"; } } You can try out by putting in echo $sql at the end. Is this what you were looking for or did I missunderstood? Luke --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
RE: Search function
Yeah what I am trying is the 'LIKE statement with OR between them'. I split the terms @ ',' into an array , trim the spaces around each word so I am left strictly with the values. But having a hard time making the search string to create. //create an array of search terms if more than 1 was entered $string = split(",", $string); foreach ($string as $key => $value) { //strip white space befor and after each term $value = trim($value); echo "Post.title LIKE '%" . $value . "%' OR Post.description LIKE '%" . $value . "%' OR "; //remove trailing OR substr_replace($string ,"",-3); The echo statement there I believe has to go but I cant figure out how to add to the "Post.title LIKE '%" . $value . "%' OR Post.description LIKE '%" . $value . "%' OR "; for each in a loop. Ideas? Thanks, Dave -Original Message- From: John Andersen [mailto:j.andersen...@gmail.com] Sent: August-12-09 8:24 AM To: CakePHP Subject: Re: Search function As soon as you have more than one word, for which to make a search for within a text, it becomes more complex! You can do as JamesF wrote, write the find, so each word is included in a LIKE statement with OR between them. You can also do as Smelly Eddie wrote, use tags instead, but the problem is to ensure that the user only enters valid tags then! Or you can use Soundex values! Or metaphone if you are using only english! See the PHP manual. Let's say you want to search for the words "cake" and "orange" in your table. The search functionality would first convert the words into soundex values. The find would then query the table records which are related to the soundex values through a HABTM relationship. contentTable -> HABTM -> soundexTable The solution means that each word in your content should be processed to create soundex values to which the content then will be related. Just an idea, maybe you could use it! :) Enjoy, John On Aug 12, 1:27 pm, Smelly Eddie wrote: > better yet avvoid storing multiplee values in one field. Create a > reference table (tags) and add those values one per record. It. Will > save the code maintainers sanity down the road > > On Aug 11, 11:32 pm, JamesF wrote: > > > some fancy combos 'LIKE' and 'OR' in your find conditions array > > should get it done. The trick is formatting your array. > > >http://book.cakephp.org/view/74/Complex-Find-Conditions > > > On Aug 11, 8:55 pm, "Dave Maharaj :: WidePixels.com" > > > wrote: > > > I am building a new search function for a input single field. > > > > I have the basic set up running but as I move forward I want the > > > user to be able to enter more than 1 word coma separated. > > > > How would I do this? > > > > spilt the $queryValues = $query split ',' > > > > So i now have an array of values that they entered but how do I > > > then query each of those values? > > > > Is there a better way to do this? > > > > thanks, > > > > Dave --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Search function
As soon as you have more than one word, for which to make a search for within a text, it becomes more complex! You can do as JamesF wrote, write the find, so each word is included in a LIKE statement with OR between them. You can also do as Smelly Eddie wrote, use tags instead, but the problem is to ensure that the user only enters valid tags then! Or you can use Soundex values! Or metaphone if you are using only english! See the PHP manual. Let's say you want to search for the words "cake" and "orange" in your table. The search functionality would first convert the words into soundex values. The find would then query the table records which are related to the soundex values through a HABTM relationship. contentTable -> HABTM -> soundexTable The solution means that each word in your content should be processed to create soundex values to which the content then will be related. Just an idea, maybe you could use it! :) Enjoy, John On Aug 12, 1:27 pm, Smelly Eddie wrote: > better yet avvoid storing multiplee values in one field. Create a > reference table (tags) and add those values one per record. It. Will > save the code maintainers sanity down the road > > On Aug 11, 11:32 pm, JamesF wrote: > > > some fancy combos 'LIKE' and 'OR' in your find conditions array should > > get it done. The trick is formatting your array. > > >http://book.cakephp.org/view/74/Complex-Find-Conditions > > > On Aug 11, 8:55 pm, "Dave Maharaj :: WidePixels.com" > > > wrote: > > > I am building a new search function for a input single field. > > > > I have the basic set up running but as I move forward I want the user to > > > be > > > able to enter more than 1 word coma separated. > > > > How would I do this? > > > > spilt the $queryValues = $query split ',' > > > > So i now have an array of values that they entered but how do I then query > > > each of those values? > > > > Is there a better way to do this? > > > > thanks, > > > > Dave --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Search function
better yet avvoid storing multiplee values in one field. Create a reference table (tags) and add those values one per record. It. Will save the code maintainers sanity down the road On Aug 11, 11:32 pm, JamesF wrote: > some fancy combos 'LIKE' and 'OR' in your find conditions array should > get it done. The trick is formatting your array. > > http://book.cakephp.org/view/74/Complex-Find-Conditions > > On Aug 11, 8:55 pm, "Dave Maharaj :: WidePixels.com" > > > > wrote: > > I am building a new search function for a input single field. > > > I have the basic set up running but as I move forward I want the user to be > > able to enter more than 1 word coma separated. > > > How would I do this? > > > spilt the $queryValues = $query split ',' > > > So i now have an array of values that they entered but how do I then query > > each of those values? > > > Is there a better way to do this? > > > thanks, > > > Dave --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Search function
some fancy combos 'LIKE' and 'OR' in your find conditions array should get it done. The trick is formatting your array. http://book.cakephp.org/view/74/Complex-Find-Conditions On Aug 11, 8:55 pm, "Dave Maharaj :: WidePixels.com" wrote: > I am building a new search function for a input single field. > > I have the basic set up running but as I move forward I want the user to be > able to enter more than 1 word coma separated. > > How would I do this? > > spilt the $queryValues = $query split ',' > > So i now have an array of values that they entered but how do I then query > each of those values? > > Is there a better way to do this? > > thanks, > > Dave --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Search function
I am building a new search function for a input single field. I have the basic set up running but as I move forward I want the user to be able to enter more than 1 word coma separated. How would I do this? spilt the $queryValues = $query split ',' So i now have an array of values that they entered but how do I then query each of those values? Is there a better way to do this? thanks, Dave --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Search Function
You should build it into pagination. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
RE: Search Function
I have this as a basic starting point. Which does the basic search of the 2 fields title and description. If I search for 1 word it works. If I use some, word, other it returns nothing. How can I search other tables for related data (TAGS) CONTROLLER: function search() { if (!empty($this->data)) { $searchstr = $this->data['Post']['search']; $this->set('searchstring', $this->data['Post']['search']); $conditions = array( 'conditions' => array( 'or' => array( "Post.title LIKE" => "%$searchstr%", "Post.description LIKE" => "%$searchstr%" ) ) ); $this->set('posts', $this->Post->find('all', $conditions)); } } VIEW: link($post['Post']['title'],'/posts/view/'.$post['Post']['id']);?> SEARCH FORM on what ever page you want to search from: create('Post',array('action' => 'search')); echo $form->input('Post.search'); echo $form->end('Submit'); ?> -Original Message- From: Mike Cook [mailto:m...@epubbooks.com] Sent: March-13-09 4:02 PM To: CakePHP Subject: Re: Search Function Hi Dave, I've just started looking into this myself. You could try these links; http://www.assembla.com/wiki/show/searchable_behavior http://thechaw.com/cakebook/source/plugins/searchable http://bakery.cakephp.org/articles/view/search-feature-to-cakephp-blog-examp le http://bakery.cakephp.org/articles/view/integrating-zend-framework-lucene-wi th-your-cake-application Hope this helps. On Mar 13, 7:15 pm, "Dave Maharaj :: WidePixels.com" wrote: > Does anyone know a starting place to read up on creating a search function? > > I want to put the search on my POSTS controller where the search will > look thru not only the POSTS but related HABTM tables. So for example > if the POST article has a TAG "Beauty" and the person searching types > in Beauty even though beauty may not have been typed into the actual > article it will still find the article based on the TAG as well. > > Dave --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Search Function
Hi Dave, I've just started looking into this myself. You could try these links; http://www.assembla.com/wiki/show/searchable_behavior http://thechaw.com/cakebook/source/plugins/searchable http://bakery.cakephp.org/articles/view/search-feature-to-cakephp-blog-example http://bakery.cakephp.org/articles/view/integrating-zend-framework-lucene-with-your-cake-application Hope this helps. On Mar 13, 7:15 pm, "Dave Maharaj :: WidePixels.com" wrote: > Does anyone know a starting place to read up on creating a search function? > > I want to put the search on my POSTS controller where the search will look > thru not only the POSTS but related HABTM tables. So for example if the POST > article has a TAG "Beauty" and the person searching types in Beauty even > though beauty may not have been typed into the actual article it will still > find the article based on the TAG as well. > > Dave --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Search Function
Does anyone know a starting place to read up on creating a search function? I want to put the search on my POSTS controller where the search will look thru not only the POSTS but related HABTM tables. So for example if the POST article has a TAG "Beauty" and the person searching types in Beauty even though beauty may not have been typed into the actual article it will still find the article based on the TAG as well. Dave --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Search function for application
I personally use a 3rd party script as a vendor for doing my searching. I think the vendor feature is very much overlooked. Combining the power of some simple yet powerful little scripts out there with CakePHP really allows for rapid development of robust applications. Anyway, check out my research here: http://www.concepthue.com/how-to/cake_search_vendor/ Quite easy to setup and I've found it effective. There are of course other 3rd party scripts you can use instead. -Tom On Apr 11, 4:45 am, "Mariano Iglesias" <[EMAIL PROTECTED]> wrote: > If you have a UsersController and a User model created, then there's no need > to declare $uses. The CamelCase of the singular version of the controller > name will be automatically linked as the main model of your controller when > not declaring $uses. > > -MI > > --- > > Remember, smart coders answer ten questions for every question they ask. > So be smart, be cool, and share your knowledge. > > BAKE ON! > > blog:http://www.MarianoIglesias.com.ar > > -Mensaje original- > De: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] En nombre > de digital spaghetti > Enviado el: Miércoles, 11 de Abril de 2007 05:23 a.m. > Para: [EMAIL PROTECTED] > Asunto: Re: Search function for application > > If its a search controller, rather than in the users controller you > need to make sure you delare $uses at the top of the contoller --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to [EMAIL PROTECTED] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
RE: Search function for application
If you have a UsersController and a User model created, then there's no need to declare $uses. The CamelCase of the singular version of the controller name will be automatically linked as the main model of your controller when not declaring $uses. -MI --- Remember, smart coders answer ten questions for every question they ask. So be smart, be cool, and share your knowledge. BAKE ON! blog: http://www.MarianoIglesias.com.ar -Mensaje original- De: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] En nombre de digital spaghetti Enviado el: Miércoles, 11 de Abril de 2007 05:23 a.m. Para: cake-php@googlegroups.com Asunto: Re: Search function for application If its a search controller, rather than in the users controller you need to make sure you delare $uses at the top of the contoller --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Search function for application
In your controller If (isset($this->data['User']['username'])) { $user = $this->User->findByUsername($this->data['User']['username']); } If its a search controller, rather than in the users controller you need to make sure you delare $uses at the top of the contoller $uses = array('User'); As long as your table fields follow cake conventions you can do any findByField(), check out the API docs for more info on it Tane On 4/11/07, szeta <[EMAIL PROTECTED]> wrote: > > Hello, > > I am using CakePHP in a project and would like to integrate a 'search' > function. > > I'm not talking about a full index for the site (like htdig), but > mainly a search function for specific fields. > > e.g. search for a person by name etc.. > > I'm not sure what's the best way to do this. > > 1. Create a model 'search' with no table and execute something like > "SELECT FROM table WHERE value LIKE '%searchvalue%'" for each field > I'd like to search. > > 2. integrate a 'search' function into each controller of the existing > models. > > Has somebody done something like this before and would like to share > his experience or link to some example code? > > In the archive and bakery I can hardly find anything about this > topic.. > > Best regards > Ralph > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Search function for application
Hello, I am using CakePHP in a project and would like to integrate a 'search' function. I'm not talking about a full index for the site (like htdig), but mainly a search function for specific fields. e.g. search for a person by name etc.. I'm not sure what's the best way to do this. 1. Create a model 'search' with no table and execute something like "SELECT FROM table WHERE value LIKE '%searchvalue%'" for each field I'd like to search. 2. integrate a 'search' function into each controller of the existing models. Has somebody done something like this before and would like to share his experience or link to some example code? In the archive and bakery I can hardly find anything about this topic.. Best regards Ralph --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---