On Thu, Mar 10, 2011 at 12:27 PM, [email protected] <[email protected]> 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
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to