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

  • SEARCH
  • Home
  • 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 9263395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T13:34:38+00:00 2026-06-18T13:34:38+00:00

I’m relatively new to CakePHP and object oriented programming. I have built apps in

  • 0

I’m relatively new to CakePHP and object oriented programming. I have built apps in CakePHP before, but never to this extent, hence the reason I’m asking for help.

I have a large product management database, the user needs to be able to set filter criteria to find the closest product matches.

The products table contains category_id, manufacturer_id, type_id, status_id related to the respective tables.

I have a sidebar with dropdown boxes for each filter, and want all the filters to work together, for instance, if a manufacturer and product type is selected, display those filtered results, and change the status and category dropdowns to only contain options from the already filtered results.

In the past I have accomplished this by using a dynamic query setting conditions based on user input, appending where clauses each time a filter was applied.

so far I’ve only been able to get individually filtered results using

$this->Product->recursive = 0;
    $mid = (isset($this->params['named']['mid'])) ? $this->params['named']['mid'] : '';
    if(!empty($mid)){
        $this->paginate = array(
            'conditions' => array('Product.manufacturer_id' => $mid),
            'limit' => 10
        );
    }
    $products = $this->paginate('Product');
    $this->set(compact('products'));

where ‘mid’ is the manufacturer id, and this is manually entering ‘mid’ in the url

How do I get cumulatively filter results if the user sets category_id, manufacturer_id, type_id, status_id or any combination? And what queries would I use to repopulate the dropdowns?

(Eventually I will use ajax, but for now assume I have 4 dropdown boxes with a submit button)

  • 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-18T13:34:39+00:00Added an answer on June 18, 2026 at 1:34 pm

    The long way would be:

    var $conditions = array();
    
    if (isset($this->params['named']['mid']) && !empty($this->params['named']['mid'])){
       $conditions['Product.manufacturer_id'] = $this->params['named']['mid']);
    }
    if (isset($this->params['named']['catid']) && !empty($this->params['named']['catid'])){
       $conditions['Product.category_id'] = $this->params['named']['catid']);
    }
    if (isset($this->params['named']['statid']) && !empty($this->params['named']['statid'])){
       $conditions['Product.status_id'] = $this->params['named']['statid']);
    }
    
    $this->paginate['conditions'] = $conditions;
    $this->paginate['limit'] = '10';
    $this->set('products', $this->paginate('Product'));
    

    Once you get the hang of that, you could put all your checks into a loop.

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

Sidebar

Related Questions

This could be a duplicate question, but I have no idea what search terms
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and

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.