Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
CakeDC Search plugin for CakePhp 2.0, multiple models
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  7 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Bob Bowen  
View profile  
 More options Jun 14 2012, 6:06 pm
From: Bob Bowen <syg...@gmail.com>
Date: Thu, 14 Jun 2012 15:06:03 -0700 (PDT)
Local: Thurs, Jun 14 2012 6:06 pm
Subject: CakeDC Search plugin for CakePhp 2.0, multiple models

Is there any way to make this work? As I understand it you have to
enable Search.Searchable in the $actsAs, and define $filterArgs for each
Model, then add Search.Prg to $components and define $presetVars in the
Controller.

Then in your .ctp file you put something like this:

echo $this->Form->create('MyModel', array('url' =>
array_merge(array('action' => 'find'), $this->params['pass'])));
echo $this->Form->input('search', array('div' => false));
echo $this->Form->submit(__('Search', true), array('div' => false));
echo $this->Form->end();

But this allows you to search in one Model at a time. Is there any way to
define a search form with one search field and have it look in various
fields within various Models?

Thanks
Bob


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
euromark  
View profile  
 More options Jun 15 2012, 4:08 am
From: euromark <dereurom...@googlemail.com>
Date: Fri, 15 Jun 2012 01:08:11 -0700 (PDT)
Local: Fri, Jun 15 2012 4:08 am
Subject: Re: CakeDC Search plugin for CakePhp 2.0, multiple models

try this one:
https://github.com/dereuromark/search

it can handle multiple fields across models for a like term etc

    'field' => array('Primary.field', 'Secondary.other_field')

Am Freitag, 15. Juni 2012 00:06:03 UTC+2 schrieb Bob Bowen:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bob Bowen  
View profile  
 More options Jun 16 2012, 7:13 pm
From: Bob Bowen <syg...@gmail.com>
Date: Sat, 16 Jun 2012 16:13:03 -0700 (PDT)
Local: Sat, Jun 16 2012 7:13 pm
Subject: Re: CakeDC Search plugin for CakePhp 2.0, multiple models

Hi and thanks for the reply.

Yea, I had seen this plugin, it's a fork of the CakeDC plugin. And I see in
the docs that you can do something like this:

class Article extends AppModel {
  public $filterArgs = array(
'enhanced_search' => array('type' => 'like', 'field' =>
array('Article.name', 'OtherModel.name'))
  }

}

But what is not explained is, how do I get the plugin to actually search
within the 'OtherModel' Model? I ask because later in the Controller you
have:

class ArticlesController extends AppController {
    public $components = array('Search.Prg');

    public $presetVars = true; // using the model configuration

    public function find() {
        $this->Prg->commonProcess();
        $this->paginate['conditions'] = $this->*Article*
->parseCriteria($this->passedArgs);
        $this->set('articles', $this->paginate());
    }

}

And in the .ctp you have:

echo $this->Form->create('*Article*', array(
    'url' => array_merge(array('action' => 'find'), $this->params['pass'])
));

As you can see, the Article Model is always referenced. So if I want to
search for a field from another model, like the 'OtherModel.name' example
above, it crashes, saying:

Column not found: 1054 Unknown column ' OtherModel.name ' in 'where clause'

The SQL is more or less:

SELECT `Article`.`id`, ... FROM `articles` WHERE ((`Article`.`name` LIKE
'%foo%') OR (`OtherModel`.`name` LIKE '%foo%'))

Obviously OtherModel.name is not going to be found in Article.

What I need to do is have a general Search box that searches in 4-5
different Models. There is no relation between those Models. So I am not
sure which Model to put the filterArgs array, which Controller to put the
presetVars array and find() function, and how to call it all in my .ctp so
that it can return results from all 5 of these Models, not just one.

Can this plugin do it?

Many thanks!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
DiabloGeto  
View profile  
 More options Jun 21 2012, 2:06 am
From: DiabloGeto <abhijatyatew...@gmail.com>
Date: Wed, 20 Jun 2012 23:06:39 -0700 (PDT)
Local: Thurs, Jun 21 2012 2:06 am
Subject: Re: CakeDC Search plugin for CakePhp 2.0, multiple models

Hi , i am quite new to cakephp, However its goin fine till now,
I want to search data , which is both from user and profile table. There
are lot of search options, that means a user can be searched from any of
his attributes or combination of all.   Further i have a search table
 which is to save all the searches done by users. My user table has basic
user info like first name , last name , email, and log in info.  Rest is in
profile. i have but all the associations requited in the models.  I am not
sure weather to implement search plugin on user model or search model.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
DiabloGeto  
View profile  
 More options Jun 28 2012, 12:07 pm
From: DiabloGeto <abhijatyatew...@gmail.com>
Date: Thu, 28 Jun 2012 09:07:50 -0700 (PDT)
Local: Thurs, Jun 28 2012 12:07 pm
Subject: Re: CakeDC Search plugin for CakePhp 2.0, multiple models

Hi all,

Plz excuse me for if i it is some thing stupid , but i tried using the
search plugin, and have got stuck , at something , and had almost no clue
to handle that.

in my find function in my controller, creates error at the line
: $this->paginate['conditions'] =
$this->Search->parseCriteria($this->passedArgs());

saying :  Call to a member function parseCriteria() on a non-object in
C:\Projects\crush\Controller\SearchesController.php .

i tried using debug($this->passedArgs());  and it shows an empty array.

Have some1 else encountered this problem, bcoz i goolged , and could not
get much. I think the problem is in declaraing passed args. But i have done
as per instructed, and can't see any error in that.

...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Julio Quinteros P.  
View profile  
 More options Jul 4 2012, 2:56 pm
From: "Julio Quinteros P." <jquin...@gmail.com>
Date: Wed, 4 Jul 2012 11:56:55 -0700 (PDT)
Local: Wed, Jul 4 2012 2:56 pm
Subject: Re: CakeDC Search plugin for CakePhp 2.0, multiple models

Hi. Recently I had to face this same issue, but with cakephp 1.3

Did you read the README.txt that came along cakedc search plugin? with that
as a starting point, I was able to build a search box where I ask not only
fields related to the main model, but also fields of related models. And
the only files required to be modified are the main model controller, and
its model file.

...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Julio Quinteros P.  
View profile  
 More options Jul 4 2012, 3:18 pm
From: "Julio Quinteros P." <jquin...@gmail.com>
Date: Wed, 4 Jul 2012 12:18:43 -0700 (PDT)
Local: Wed, Jul 4 2012 3:18 pm
Subject: Re: CakeDC Search plugin for CakePhp 2.0, multiple models

oops, my message was meant to you Bob, sorry

* *

*Hi. Recently I had to face this same issue, but with cakephp 1.3 *

*Did you read the README.txt that came along cakedc search plugin? with


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »