Products module - search action help needed
Products module - search action help needed
I'm loving the Products module - it seems really powerful.
I have a couple of questions regarding the "search" action of the module:
1. How do you create a field in the search form to search by Category or combinations of Categories? The sample search template shows how you can add controls for a number of different criteria including Field Definitions (custom fields), but I can't see how to add Categories to the search form.
2. The sample search template shows how to add controls for Text-type and Dropdown-type Field Definitions (custom fields) to the search form, but how do you add Checkbox-type or other types to the search form?
Thanks.
I have a couple of questions regarding the "search" action of the module:
1. How do you create a field in the search form to search by Category or combinations of Categories? The sample search template shows how you can add controls for a number of different criteria including Field Definitions (custom fields), but I can't see how to add Categories to the search form.
2. The sample search template shows how to add controls for Text-type and Dropdown-type Field Definitions (custom fields) to the search form, but how do you add Checkbox-type or other types to the search form?
Thanks.
Re: Products module - search action help needed
Anyone?
Categories are pretty fundamental to this module - there's gotta be a way to get them into the search form, isn't there?
Categories are pretty fundamental to this module - there's gotta be a way to get them into the search form, isn't there?
Re: Products module - search action help needed
Did you figure out how to include the categories into your search?
I have thought about adding in a custom dropdown field called category and using this as my category but their has to be a way to use the standard category feature in your search.
Thanks,
Paul
I have thought about adding in a custom dropdown field called category and using this as my category but their has to be a way to use the standard category feature in your search.
Thanks,
Paul
Re: Products module - search action help needed
No, I haven't found a solution to this yet.
CTLModuleMaker is an alternative module to consider - it has a search function too.
CTLModuleMaker is an alternative module to consider - it has a search function too.
Re: Products module - search action help needed
Hey Cerulean,
I have been searching everywhere for a way to add my custom fields to the search criteria (in essence I am trying to create an "Advanced Search" form) and noticed that you said:
Have you any ideas?
Marc
I have been searching everywhere for a way to add my custom fields to the search criteria (in essence I am trying to create an "Advanced Search" form) and noticed that you said:
The sample search template that I have doesn't seem to have this info in it and I really am struggling to get any of my Custom fields to show up in the searches.The sample search template shows how you can add controls for a number of different criteria including Field Definitions (custom fields)
Have you any ideas?
Marc
Re: Products module - search action help needed
Henson, I wish I could help more, but I struggled with the products module and now the project I was going to use it in is on hold so I haven't made any further progress.
You'll see I said:
EDIT: they do appear, but as empty dropdown boxes. To fix this, in the code from the sample template below, change {if $obj->type == 'text'} to {if $obj->type == 'textbox'} or {if $obj->type == 'textarea'}
Here is the relevant code from the sample template:
It would be great if Calguy could give us some help here.
You'll see I said:
So the sample template is only useful if the Field Definitions you have added are Text-type or Dropdown-type. And having said that, I just tested the two text-type options of "Text input" and "Text area" and they didn't appear in the search box so I don't know what's up there.2. The sample search template shows how to add controls for Text-type and Dropdown-type Field Definitions (custom fields) to the search form, but how do you add Checkbox-type or other types to the search form?
EDIT: they do appear, but as empty dropdown boxes. To fix this, in the code from the sample template below, change {if $obj->type == 'text'} to {if $obj->type == 'textbox'} or {if $obj->type == 'textarea'}
Here is the relevant code from the sample template:
Code: Select all
{if isset($searchprops)}
{foreach from=$searchprops key='propname' item='obj'}
<div class="row">
<p class="row_prompt">{$obj->prompt}:</p>
<p class="row_input">
{if $obj->type == 'text'}
<input type="text" name="{$actionid}cd_propvalue[{$propname}]" size="40" maxlength="40"/>
{else if $obj->type == 'dropdown'}
<select name="{$actionid}cd_propvalue[{$propname}]">
{html_options options=$obj->options}
</select>
{/if}
</p>
</div>
{/foreach}
{/if}
Last edited by Cerulean on Fri Sep 16, 2011 5:00 am, edited 2 times in total.
Re: Products module - search action help needed
Why not just use the search module and restrict it to just searching the Products module as this will search all data in Products.
Re: Products module - search action help needed
Applejack, I'm not sure if your suggestion was directed to me or henson, but in my case the objective was to create an "Advanced Search" where a user can find products in Category 1 AND Category 4, or with Custom Field 1 AND Custom Field 2, etc.
The usefulness of categories and custom fields in this module is greatly diminished by the fact that there is no documented way of including them in a search.
The usefulness of categories and custom fields in this module is greatly diminished by the fact that there is no documented way of including them in a search.
Re: Products module - search action help needed
You cannot search more than one custom field at a time. I recently need to do this myself on a project and asked Calguy who said he would do this as a paid job to which I agreed to the fee and then never heard back from him.
You can search multiple categories and hierarchies though.
There are ways of hacking the search to return results from multiple custom fields by using conditional statements within the foreach loop but it can get complicated and you need to write your own pagination routine. Just depends what exactly you need to be able to do.
You can search multiple categories and hierarchies though.
There are ways of hacking the search to return results from multiple custom fields by using conditional statements within the foreach loop but it can get complicated and you need to write your own pagination routine. Just depends what exactly you need to be able to do.
Re: Products module - search action help needed
Do you mean by using the normal CMSMS {search} module?You can search multiple categories and hierarchies though.
The problem with this is that the user only has a text search field and isn't going to know what categories are available.
Or is it possible to create a more advanced search with the {search} module that uses dropdowns or checkboxes?
Re: Products module - search action help needed
No not using the search module or the search option of the products module. Using drop downs or checkboxes.
I have only done this using custom fields and the using the fieldlist action to populate the drop downs but I think you can also do this for categories. So say you have your drop downs and then you point the form action to a specific page and then you capture each value selected from the drop downs and then pass them to the summary action in the call to the Products module. So in the page content block or template you have i.e. (fieldid='4' the number relates to the custom field id you wish to search)
I have only done this using custom fields and the using the fieldlist action to populate the drop downs but I think you can also do this for categories. So say you have your drop downs and then you point the form action to a specific page and then you capture each value selected from the drop downs and then pass them to the summary action in the call to the Products module. So in the page content block or template you have i.e. (fieldid='4' the number relates to the custom field id you wish to search)
Code: Select all
{if $smarty.post.dropdown_value_1 || $smarty.post.dropdown_value_2}
{assign var=dropdown_value_1 value=$smarty.post.dropdown_value_1}
{assign var=dropdown_value_2 value=$smarty.post.dropdown_value_2}
{capture assign=collect}{Products fieldid='4' fieldval="$dropdown_value_1" sortorder='asc' summarytemplate='collection' category="$dropdown_value_2" pagelimit='12'}{/capture}
{if $collect}
{$collect}
{else}
No Results Found for "{$smarty.post.dropdown_value_1} or {$smarty.post.dropdown_value_2}"
{/if}
{/if}
Re: Products module - search action help needed
Thanks for sharing your code, applejack.
I'll be sure to give it a try in my project when it gets underway.
I'll be sure to give it a try in my project when it gets underway.
Re: Products module - search action help needed
No problem. Any other questions about this just ask.
Re: Products module - search action help needed
I'm also looking to create an advanced search form for products but I'm struggling to understand how to amend the default search form template to search through my field definitions.
For example I have the following field definitions that I'd like the user to be able to filter:
- Model / Reference Number
- Price (which is already in the template)
- New / Used
- Capacity
All of the above would be drop downs apart from the model / ref number and would work in the same way to Price. The model / ref number in the search form would be text input.
Can anyone offer any help or point me in the right direction to a tutorial? I've searched for a tutorial but couldn't find anything and the module help section doesn't have information on this either.
Thanks in advance
For example I have the following field definitions that I'd like the user to be able to filter:
- Model / Reference Number
- Price (which is already in the template)
- New / Used
- Capacity
All of the above would be drop downs apart from the model / ref number and would work in the same way to Price. The model / ref number in the search form would be text input.
Can anyone offer any help or point me in the right direction to a tutorial? I've searched for a tutorial but couldn't find anything and the module help section doesn't have information on this either.
Thanks in advance
Re: Products module - search action help needed
You can only search ONE custom field. It is because of the way the DB is set up and so the help documentation is wrong. I have tried and I know for sure it doesn't work. The only work around is to use conditional statements in the foreach loop of a summary template but this can get very complicated depending upon the number of search options.
So either set up your products structure using categories and hierarchies and one searchable custom field or ask Calguy to re-write it and see if he ever gets back to you.
So either set up your products structure using categories and hierarchies and one searchable custom field or ask Calguy to re-write it and see if he ever gets back to you.