Dynamically Filter by Field content

7 posts by 2 authors in: Forums > CMS Builder
Last Post: March 25, 2011   (RSS)

By gadefgaertgqe - March 22, 2011 - edited: March 22, 2011

Hi all :)

I am creating a database list of new scooters for a website.

All the scooters are held in one section, each scooter is a record.

For each scooter record I have various fields of information. However the ones I am interested in filtering by have drop downs and check boxes to specify the following:

1 - Model Family (drop down)
2 - Engine Size (drop down)
3 - Colour (multi choice check boxes)
4 - Cooling system (drop down)

What I am trying to achieve is:

1 - Detect what model families there currently are, and then take the first example of each one to create a list. I can output a list but after that I get stuck.

2 - Detect what the current engine sizes, colour options and cooling systems are in the database and be able to filter by those options.

So for example using test data I have put into the database consistaing of 4 bikes from 2 Model Families:
foreach ($peugeot_products_scootersRecords as $scooterRecords):;
echo $scooterRecords["model_range"];
endforeach;


Gives me:
VivacityVivacitySpeedfight 3Speedfight 3



I've been working on this for a while and find myself going round in circles lol! Am I going about this the wrong way? Should I maybe be doing it this way:
http://www.interactivetools.com/iforum/Products_C2/CMS_Builder_F35/Sub-categories_Tutorial_P77230/


Paul

Re: [Jason] Dynamically Filter by Field content

Hi Jason,

For the Model Family I want to display the first scooter in the list. So there will be one example of each Model Family which will form a list for people to choose from. When they click on an example, they will then go to a page listing all members of that Model Family.

As for the other 'filters' yes drop down is what I plan to use but open the other methods.

All information is stored in each individual bike array. So the bike array contains the engine size, model family, etc.

Hope this makes sense if not I will check my mail from home later and try to clarify any points for you.

Thanks for getting back to me :)

Paul

Re: [Pixels & Beats] Dynamically Filter by Field content

By Jason - March 22, 2011

Hi Paul,

How is the information being structured in CMS Builder. For example, for the model field in the bike section, is this a dropdown that is pulling from a model section, or is it a drop down where you typed in all the options into the field.

Let me know
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Dynamically Filter by Field content

Hi Jason,

For the Model Range I added a list field into the bike section which I then populated with all the models in the list options section.

I have attached some photos to try and help :)

Kind regards

Paul
Attachments:

main.jpg 111K

model-range.jpg 36K

Re: [Pixels & Beats] Dynamically Filter by Field content

By Jason - March 23, 2011

Hi Paul,

Okay, in that case, you can use the function getListOptions to get the possible list options that you have stored in the CMS. You're code to set up a drop down box for model_range, for example, would look like this:

<select name = "model_range" >

<?php foreach (getListOptions('bikes', 'model_range') as $value => $label): ?>

<option value = "<?php echo $value;?>" <?php selectedIf($value, @$_REQUEST['model_range']);?>><?php echo $label; ?></option>

<?php endforeach ?>

</select>


Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Dynamically Filter by Field content

Thanks Jason!

This looks like a good starting point. Will investigate after the weekend. Hope you have a good one!

Paul