Anyone??? I am still struck in the same prob..

On Mar 15, 10:54 pm, aman batra <[email protected]> wrote:
> i have a searches controller and the index function of it is :-
>
>  function index($searchstr, $by='Entity')
>      {
>       $conditions = array();
>         switch($by) {
>         case 'Tags':
>         case 'doc':
>         case 'video':
>         case 'image':
>         case 'slide':
>                 $modelName = 'Entity';
>                 if ($by=='doc'||'video'||'image'||'slide') {
>                         $conditions = array('Entity.type'=>$by);
>                 }
>                 break;
>         default:
>                 $modelName = $by;
>                 break;
>        }
>
>             if(empty($searchstr))
>             {
>                     $error = 'No search string found';
>                     $this->set('error',$error);
>
>             }
>             else
>                 {
>                     $fltrstr = urldecode($searchstr);
>
>                     if ($modelName == 'Entity')
>                     {
>                         if ($by == 'Tags') {
>                                 $match_fields = array('Entity.tags');
>                         }
>                         else {
>                                 $match_fields = array('Entity.title',
> 'Entity.description', 'Entity.tags');
>                         }
>
>                         // The required fields for the o/p are fetched.
>                         $match_string = implode(",", $match_fields);
>                        $conditions = array_merge(array(" MATCH($match_string)
> AGAINST (('$fltrstr')) AND `Entity`.`status`='Y' AND
> `Entity`.`approved`='Y'"),
>                                                                            
> $conditions);
>
>                         // The page title and the tags implementation.
>                         $this->pageTitle = "$searchstr - Videos,
> Presentations, Pics, Documents on $searchstr | ABC";
>                         $this->set('meta_tags',
>                                                 "$searchstr, $searchstr 
> videos, $searchstr presentations,
> $searchstr pics, $searchstr documents, $searchstr images");
>                                             $this->set('meta_desc',
>                                                 "$searchstr - Get thousands 
> of videos, slides, pics & documents
> on $searchstr - the best of internet collected at ABC");
>
>                                         // Save the search query.
>                                         
> $this->SearchLog->save(array('SearchLog'=>array('query'=>
> $searchstr, 'type'=>'A')));
>
>                                         // Find Related Searches.
>                                         $match_fields = 
> array('SearchLog.query');
>                         $match_string = implode(",", $match_fields);
>
>                         $logconditions = array(" MATCH($match_string)AGAINST
> (('$fltrstr'))");
>
>                         $queries = $this->SearchLog->find('all', array
> ('conditions'=>$logconditions));
>
>                         $this->set('queries', $queries);
>                     }
>                     else
>                     {
>                         $match_fields = array
> ('User.first_name','User.last_name',
>                             'User.email_address', 'User.uid');
>
>                                         // The required fields for the o/p 
> are fetched.
>                         $match_string = implode(",", $match_fields);
>
>                         $conditions = array(" MATCH($match_string)AGAINST
> (('$fltrstr')) AND `User`.`account_status`='Y'");
>
>                         // The page title and the tags implementation.
>                         $this->pageTitle = "Users Matching $searchstr | ABC";
>                         $this->set('meta_tags', "$searchstr, Users");
>                                         $this->set('meta_desc', "Users 
> Matching $searchstr on ABC");
>                     }
>
>                     $data = $this->paginate($modelName, $conditions);
>
>                     if(empty($data)){
>                         $error = 'No data matching your string';
>                         $this->set('error', $error);
>                     }
>
>                      // Filters the string
>                     $this->set('res', $data);
>             }
>
>             $this->set('by',$by);
>             $this->set('keyword',$searchstr);
>             $this->render($modelName);
>    }
>
> }
>
> And its corresponding view element of displaying result and
> paginating  is :-
>
> if ($this->params['controller'] == 'searches') {
>                                                                               
>           $paginator->options(array('url'=>$this-
>
> >passedArgs));
>
> Now corresponding to the above code whenever i search for a string say
> "joke" on my site then my url iswww.abc.com/search/jokeand is also paginating 
> fine.
> but as I filter my result according to its type like(videos,
> documents, etc)
> then the url iswww.abc.com/search/joke/videowhich is ok but when i click for 
> the
> next page the url is
>
> www.abc.com/search/joke/joke/video/page:1and so on... the
> searchstring comes twice..
>
> I am unable to tackle this one..
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to