Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7952671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:55:51+00:00 2026-06-04T02:55:51+00:00

I’m using cakephp 2.1 and cakedc search plugin. The thing is I can’t glue

  • 0

I’m using cakephp 2.1 and cakedc search plugin.
The thing is I can’t glue it together. Also got:

Notice (8): Indirect modification of overloaded property ProjectsController::$paginate has no effect [APP\Controller\ProjectsController.php, line 48]

Followed cakedc tutorial but something’s missing! Simple search just won’t filter anything.
I want to filter by name field.

On my projects model

public $actsAs = array('Search.Searchable');
var $name = 'Project';

public $filterArgs = array(
       array('name' => 'name', 'type' => 'like'),
       array('name' => 'filter', 'type' => 'query', 'method' => 'orConditions'),
);

public function orConditions($data = array()) {
            $filter = $data['filter'];
            $cond = array(
                'OR' => array(
                    $this->alias . '.name LIKE' => '%' . $filter . '%',
                    //$this->alias . '.body LIKE' => '%' . $filter . '%',
                    ));
            return $cond;
        }

in my controller:

public $components = array('Search.Prg');

public $presetVars = array(
    array('field' => 'name', 'type' => 'value')
);

index function updated to use index.ctp only (no find function)

public function index() {
    $this->Prg->commonProcess();
    $this->Project->recursive = 0;
    // next line causes
    // Notice (8): Indirect modification of overloaded property ProjectsController::$paginate has no effect [APP\Controller\ProjectsController.php, line 48] 
    //$this->paginate['conditions'] = $this->Project->parseCriteria($this->passedArgs);
    $this->set('projects', $this->paginate());
}

and added search form to view.ctp

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

I know this must be some obvious error on my part, please bear with me.
Can anyone help?

Thanks a lot !

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T02:55:53+00:00Added an answer on June 4, 2026 at 2:55 am

    I’m glad to let people know I found my way to use cakedc search plugin.

    First I had to closely follow this tutorial for 1.3 (at first I thought it won’t do for 2.1, but it works like charm.)

    http://www.youtube.com/watch?v=FAVuLXFVaCw

    AND downloaded 1.3 sample code from cakedc
    http://cakedc.com/eng/downloads/view/cakephp_search_plugin
    to make sense of video tutorial. (tried to run it following readme instructions but got error Fatal error: Class ‘Dispatcher’ not found in C:\wamp\www\search\webroot\index.php on line 83 so
    chose to just get code snippets and have them work in 2.1)

    Back to my project:

    1.- Downloaded search version 2.1 from cakedc https://github.com/CakeDC/search,
    file CakeDC-search-2.1-0-g834f79f.zip.

    2.- Placed all files on /plugins/Search/ folder

    3.- Added

    CakePlugin::load('Search');  
    

    to the bottom of /Config/bootstrap.php

    4.- On my controller, declared the component and presetVars (I’m using a field called name)

    public $components = array('Search.Prg');
    public $presetVars = array(
        array('field' => 'name', 'type' => 'value'),
        array('field' => 'pr_status', 'type' => 'value'),
    );
    

    5.- and updated my index function:

    public function index() {
        $this->Prg->commonProcess();
        $this->paginate = array(
            'conditions' => $this->Project->parseCriteria($this->passedArgs));
        $this->set('projects', $this->paginate());
    }
    

    6.- on my model, added

            public $actsAs = array('Search.Searchable');
    
            public $filterArgs = array(
                array('name' => 'name', 'type' => 'query', 'method' => 'filterName'),
                array('name' => 'pr_status', 'type' => 'value'),
            );
    
            public function filterName($data, $field = null) {
                if (empty($data['name'])) {
                    return array();
                }
                $nameField = '%' . $data['name'] . '%';
                return array(
                    'OR' => array(
                        $this->alias . '.name LIKE' => $nameField,
                        ));
            }
    
            // Built a list of search options (unless you have this list somewhere else)
            public function __construct($id = false, $table = null, $ds = null) {
            $this->statuses = array(
                        '' => __('All', true),
                         0 => __('Bid', true),
                         1 => __('Cancelled', true),
                        2 => __('Approved', true),
                        3 => __('On Setup', true),
                        4 => __('Field', true),
                        5 => __('Closed', true),
                        6 => __('Other', true));
             parent::__construct($id, $table, $ds);
             }
    

    7.- Lastly, created the search form on index.ctp, right above the table tag

        <div><?php
            echo $this->Form->create('Project', array(
                'url' => array_merge(array('action' => 'index'), $this->params['pass'])
                ));
            echo $this->Form->input('name', array('div' => false, 'empty' => true)); // empty creates blank option.
                    echo $this->Form->input('pr_status', array('label' => 'Status', 'options' => $statuses));
            echo $this->Form->submit(__('Search', true), array('div' => false));
            echo $this->Form->end();
        ?>
            </div>
    

    I also learned not to discard 1.3 tutorials and documentation even though i’m using 2.1.
    Next step is to filter by dates and a nicer search form.

    Good luck everybody.

    Carlos

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.