<p>If I understand correctly, it looks like you really only have 2 branches to your tree (products and services). Everything else applies to all products or all services respectively and is one-to-one (except for budget). Instead of using categories, I would probably opt for using <code>Entry Type</code> to determine whether it's a product or service, and dropdown and/or checkbox fields to determine the product/service attributes, which you can then use to search for products/services directly using an <code>ElementCriteriaModel</code>.</p>

<pre><code>Channel =&gt; productsServices
    Entry Type =&gt; product
        Field =&gt; testingType (dropdown)
        Field =&gt; surfaceType (dropdown)
    Entry Type =&gt; service
        Field =&gt; reportingLevel (dropdown)
        Field =&gt; isoCertification (checkbox)
        Field =&gt; price
</code></pre>

<p>In your template, you can use javascript to display the correct form questions (based on the answer to the first question) using <code>.on('change', function(event){..}</code>). Select field options can be set dynamically from the field options. Budget options can perhaps be stored in a separate field in a global set ('budgetOptions') for example.</p>

<pre><code>Who will test your self-cleaning surface?
&lt;select name="productServiceType"&gt;
    &lt;option value="product"&gt;I'll test it myself&lt;/option&gt;
    &lt;option value="service"&gt;I want the experts&lt;/option&gt;
&lt;/select&gt;

&lt;div class="product-questions" style="display:none"&gt;
    What is the reason for your testing?
    &lt;select name="testingType"&gt;...&lt;/select&gt;
    What surface type will you be testing?
    &lt;select name="surfaceType"&gt;...&lt;/select&gt;
&lt;/div&gt;

&lt;div class="services-questions" style="display:none"&gt;
    What level of reporting do you require?
    &lt;select name="reportingLevel"&gt;...&lt;/select&gt;
    Do you require ISO certification?
    &lt;select name="isoCertification"&gt;...&lt;/select&gt;
    What is your budget?
    &lt;select name="budget"&gt;...&lt;/select&gt;
&lt;/div&gt;
</code></pre>

<p>You can then submit the form to your productServices template, retrieve the attributes and find the associated products/services.</p>

<pre><code>{# set default params #}
{% set params = {
    section: 'productsServices',
    limit: null
} %}

{# determine productService Type #}
{% set type = craft.request.getParam('productServiceType') %}

{# set product params #}
{% if type == "product" %}
    {% set testingTypeParam = craft.request.getParam('testingType') %}
    {% set surfaceTypeParam = craft.request.getParam('surfaceType') %}
    {% set params = params|merge([
        testingType: testingTypeParam, 
        surfaceType: surfaceTypeParam 
    ]) %}
{% endif %}

{# set service params #}
{% if type == "service" %}
    {% set reportingLevelParam = craft.request.getParam('reportingLevel') %}
    {% set isoCertificationParam = craft.request.getParam('isoCertification') %}
    {% set budgetParam = craft.request.getParam('budget') %}
    {% set params = params|merge( [
        reportingLevel: reportingLevelParam, 
        isoCertification: isoCertificationParam
        price: '&gt;= ' ~ budgetParam
    ]) %}
{% endif %}

{# retrieve entries #}
{% set entries = craft.entries(params) %}
{% for entry in entries %}
    {{ title }}
    ...
{% endfor %}
</code></pre>

<p>Not tested, but should be close.</p>

CC BY-SA 3.0
2015-01-05T19:53:40.347Z
Cheers - the whole logic of that works very well and fully understand it. Couple of things which complicate it. It is not a straight split between Products and Services. On my initial products/services page it has Inks, Acessories, Kits and Services. Each of those has an image as well. Would that work with an entry type. Also on the Homepage I have a section for what product would it be used on with images for each. If that is a checkbox option I can hardly have images for each option?
mmc501
CC BY-SA 3.0
2015-01-05T20:09:22.383Z
`Entry types` allow you to customize all the fields, so yes.. it would support images or anything else you need. However, placing products and services in the same channel is really optional. You could adapt this to use separate product/service channels if needed. You would just want to move the 'section' parameter from the 'default params' to the 'conditional params' if that makes sense.
Douglas McDonald
CC BY-SA 3.0
2015-01-05T20:18:34.777Z
You could also change the products/services channel to a structure with 'inks, accessories, kits, and services' as parent entries, with an Entry Type called 'landingPage' or 'index' or 'productServiceType' for example, where you could define additional fields for 'feature image', 'description', etc.
Douglas McDonald
CC BY-SA 3.0
2015-01-05T20:20:26.547Z
Regarding the homepage issue.. are you saying you have sample images for each option?
Douglas McDonald
CC BY-SA 3.0
2015-01-05T20:25:28.200Z
Yep I have sample images for each option - glass, concrete, tiles etc. You have got me thinking though, it will probably be possible to use the forms as you suggested and with JavaScript build a url with the specific options and load that. It would prob work with what I already have.
mmc501
CC BY-SA 3.0
2015-01-05T20:33:28.610Z
Sounds like perhaps 'surface type' would be a good candidate for categories (especially if it's a many-to-one relationship, which it might be). Perhaps a combination of using drop-down/checkbox for static options and categories for surface type(s) would be the way to go. You can easily add a 'relatedTo' parameter to the 'params' above to retrieve products with the chosen categories.
Douglas McDonald
CC BY-SA 3.0
2015-01-05T20:53:00.700Z
Cheers. Will go with that. Mixture of categories and checkboxes. You've kicked my brain into action now. Thanks for the help!
mmc501
CC BY-SA 3.0
2015-01-05T19:25:13.117Z
2015-01-05T19:36:55.547Z
2015-01-05T19:36:55.547Z
Douglas McDonald
<p>I have a channel on my site which holds the products and services available.
Each has various categories to narrow it down. I want to build a product selector and not sure the best method to go about it.
Concept is in image:
<img src="https://i.sstatic.net/5YIfi.gif" alt="enter image description here"></p>

<p>The first 3 questions are filters by categories which apply to each product/service. The Q4 is a price which each product/service has.</p>

<p>I already have a page set up with a custom route which filters the products based on the categories e.g:</p>

<p>/products-services/inks/sales-marketing/tiles  which is
/(to load template)/category/category/category</p>

<p>And that currently filters the products as required.</p>

<p>What is my best way to build the product selector? I'm guessing it is to build a url somehow and link to the above route I have already set up?
Could it be done with a structure with a sub level for each question?</p>

<entries><structure><filter>
Best Way to Build a Product Selector
# Best Way to Build a Product Selector

(Asked by: username_0 on 2015-01-05)

I have a channel on my site which holds the products and services available.
Each has various categories to narrow it down. I want to build a product selector and not sure the best method to go about it.
Concept is in image:
![enter image description here](https://i.sstatic.net/5YIfi.gif)

The first 3 questions are filters by categories which apply to each product/service. The Q4 is a price which each product/service has.

I already have a page set up with a custom route which filters the products based on the categories e.g:

/products-services/inks/sales-marketing/tiles which is
/(to load template)/category/category/category

And that currently filters the products as required.

What is my best way to build the product selector? I'm guessing it is to build a url somehow and link to the above route I have already set up?
Could it be done with a structure with a sub level for each question?

**Tags:** entries, structure, filter

---

## 1 answers

### Answer by username_1 on 2015-01-05. Score: 2 | Accepted answer

If I understand correctly, it looks like you really only have 2 branches to your tree (products and services). Everything else applies to all products or all services respectively and is one-to-one (except for budget). Instead of using categories, I would probably opt for using Entry Type to determine whether it's a product or service, and dropdown and/or checkbox fields to determine the product/service attributes, which you can then use to search for products/services directly using an ElementCriteriaModel.
Channel => productsServices
    Entry Type => product
        Field => testingType (dropdown)
        Field => surfaceType (dropdown)
    Entry Type => service
        Field => reportingLevel (dropdown)
        Field => isoCertification (checkbox)
        Field => price

In your template, you can use javascript to display the correct form questions (based on the answer to the first question) using .on('change', function(event){..}). Select field options can be set dynamically from the field options. Budget options can perhaps be stored in a separate field in a global set ('budgetOptions') for example.
Who will test your self-cleaning surface?

    I'll test it myself
    I want the experts



    What is the reason for your testing?
    ...
    What surface type will you be testing?
    ...



    What level of reporting do you require?
    ...
    Do you require ISO certification?
    ...
    What is your budget?
    ...


You can then submit the form to your productServices template, retrieve the attributes and find the associated products/services.
{# set default params #}
{% set params = {
    section: 'productsServices',
    limit: null
} %}

{# determine productService Type #}
{% set type = craft.request.getParam('productServiceType') %}

{# set product params #}
{% if type == "product" %}
    {% set testingTypeParam = craft.request.getParam('testingType') %}
    {% set surfaceTypeParam = craft.request.getParam('surfaceType') %}
    {% set params = params|merge([
        testingType: testingTypeParam, 
        surfaceType: surfaceTypeParam 
    ]) %}
{% endif %}

{# set service params #}
{% if type == "service" %}
    {% set reportingLevelParam = craft.request.getParam('reportingLevel') %}
    {% set isoCertificationParam = craft.request.getParam('isoCertification') %}
    {% set budgetParam = craft.request.getParam('budget') %}
    {% set params = params|merge( [
        reportingLevel: reportingLevelParam, 
        isoCertification: isoCertificationParam
        price: '>= ' ~ budgetParam
    ]) %}
{% endif %}

{# retrieve entries #}
{% set entries = craft.entries(params) %}
{% for entry in entries %}
    {{ title }}
    ...
{% endfor %}

Not tested, but should be close.

> **Comments:**
> **username_0**: Cheers - the whole logic of that works very well and fully understand it. Couple of things which complicate it. It is not a straight split between Products and Services. On my initial products/services page it has Inks, Acessories, Kits and Services. Each of those has an image as well. Would that work with an entry type. Also on the Homepage I have a section for what product would it be used on with images for each. If that is a checkbox option I can hardly have images for each option?  
> **username_1**: `Entry types` allow you to customize all the fields, so yes.. it would support images or anything else you need. However, placing products and services in the same channel is really optional. You could adapt this to use separate product/service channels if needed. You would just want to move the 'section' parameter from the 'default params' to the 'conditional params' if that makes sense.  
> **username_1**: You could also change the products/services channel to a structure with 'inks, accessories, kits, and services' as parent entries, with an Entry Type called 'landingPage' or 'index' or 'productServiceType' for example, where you could define additional fields for 'feature image', 'description', etc.  
> **username_1**: Regarding the homepage issue.. are you saying you have sample images for each option?  
> **username_0**: Yep I have sample images for each option - glass, concrete, tiles etc. You have got me thinking though, it will probably be possible to use the forms as you suggested and with JavaScript build a url with the specific options and load that. It would prob work with what I already have.  
> **username_1**: Sounds like perhaps 'surface type' would be a good candidate for categories (especially if it's a many-to-one relationship, which it might be). Perhaps a combination of using drop-down/checkbox for static options and categories for surface type(s) would be the way to go. You can easily add a 'relatedTo' parameter to the 'params' above to retrieve products with the chosen categories.  
> **username_0**: Cheers. Will go with that. Mixture of categories and checkboxes. You've kicked my brain into action now. Thanks for the help!  

---

