Wednesday, March 9, 2011

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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate