diegonella Posted June 8, 2012 Share Posted June 8, 2012 I want to make a filter with concatenated criteria for cars for example brand: Ford, Chevrolet, Fiat models: Mustang, Corvette, Fiat 500 year: 1980, 2001, 2003 and clicking at Ford, in models should only be Mustang Each car is loaded as a subpage of Cars and the search criteria are fields page Similar to Refine search from http://motors.shop.ebay.com/6001/i.html thanks Link to comment Share on other sites More sharing options...
ryan Posted June 11, 2012 Share Posted June 11, 2012 There are a number of ways to do this, but for the purposes of an example, lets look at your first one: Brand. Lets say you've got your brands as pages here: /brands/acura/ /brands/audi/ /brands/ford/ ...etc. Your search form might look like this: $checkedBrands = $input->whitelist('brands'); if(!is_array($checkedBrands)) $checkedBrands = array(); foreach($pages->get('/brands/')->children as $brand) { if(in_array($brand->id, $checkedBrands)) $checked = " checked='checked'"; echo "<label><input type='checkbox' name='brands[]' value='{$brand->id}' $checked> {$brand->title}</label>"; } And your search processor might look like this: $selector = ''; if(is_array($input->get->brands)) { $brands = array(); foreach($input->get->brands as $brand) $brands[] = (int) $brand; $input->whitelist('brands', $brands); if(count($brands)) $selector .= "brands=" . implode('|', $brands) . ", "; } $vehicles = $pages->find("template=vehicle, $selector"); Now when it comes to showing something like models, you'd either want the models to have a page reference selecting a brand they relate to, or you'd want to make the models children of the brand. That should make it fairly easy to determine your models once you know the brands: $models = new PageArray(); foreach($brands as $brand) { $models->import($pages->get((int) $brand)->children); } 2 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now