I have a relatively simple structure for products that I am building an advanced search for. I access the products using craft.entries.section('products'), but these products have fields with options for those fields within them.
So my question is, how do I access these? This is my attempt so far.
{% set parameters=
{
section: 'products',
limit: '1'
}
%}
{% set query = craft.request.getParam('entry') %}
{% if query %}
{% set entries = craft.entries(parameters).relatedTo(query).order('score') %}
{% else %}
{% set entries = craft.entries(parameters) %}
{% endif %}
I know this is incorrect, because I need to look at an object within an object within products and check a field belonging it. For instance, if the product was a phone, it would have something like "mobilityOptions" and under that would be "Cordless", "Desk", and "Wall".
My search form has got those mobility options through a for option in products loop of the section, followed by a for block in option.mobilityOptions.options that then makes checkboxes for each option, but to use it with the ".relatedTo" functionality I don't think it would work.
onSaveEntryevents, loops the checkboxes options and stores the relations to the new field (which you could hide with CSS from the CP). You'd just have to make sure to have a matching category for each checkbox option and find a way to link them (e.g., category slug matches checkbox option value). – carlcs Jan 13 '16 at 15:05