User Tools

Site Tools


Sidebar

tutorials:design_adv:examples:checkbox_to_dropdown_in_search

Change the Checkbox Choices in the Search Form to Dropdowns

This tutorial will point you to where changes would need to be made to system templates to make the dropdown questions you setup in the category specific questions and site wide optional fields display as dropdowns in the advanced search page. Before you attempt this customization you should know there is a reason that checkboxes appear in the first place. The checkboxes allow your clients the ability to choose more than one option for that question to fit their search criteria. A dropdown choice only allows one choice from those available. If you still want to proceed with the change carry on with this tutorial.

This tutorial is for advanced users of the software who have html and Smarty code experience. Do not attempt unless you have a firm grasp of each and the ability to debug the changes you make if you run into a problem. Support cannot help with your php code or system template changes like the ones you would make below. One thing to know is if you follow the guidelines in “custom system template changes” wiki article here you will always be able to restore yourself to the default template if needed.

The changes here will explore the category specific question system template you see in the advanced search form. Those changes specifically deal with the following system template:

/geo_templates/[your template set - not default]/system/other/ajax_searchQuestions.tpl

And as always follow these guidelines when making system/module template changes as the /default template set is over written in an update:

http://geodesicsolutions.com/support/geocore-wiki/doku.php/id,tutorials;design_adv;replace_system_templates/

If you find you get stuck or lost with your changes and want to “start over” or just scrap what you have you can always delete the:

/system/other/ajax_searchQuestions.tpl

template in your custom template set. That will tell the system to use the same system template in the default template set that you didn't make your changes to (correct?).

After you get the above template copied from your default template set to your custom template set open it within your DESIGN > MANAGER source code editor or locally in your own text editor and search for "checkbox". That should illuminate the main areas of the file you will be looking to edit.

There are two areas in that file that displays the checkboxes for "dropdown questions". The first section of code you'll find is for the site wide optional fields that are dropdowns and looks like this:

<ul>
	{foreach $field.dropdown as $val}
		{if $val.value}
			<li><label><input type="checkbox" name="b[optional_field_{$i}][]" value="{$val.value|escape}" {if $val.selected}checked="checked"{/if} /> {$val.value}</label></li>
		{/if}
	{/foreach}
</ul>

And you would replace with something like this. And note this is by no means the only solution.

       <select class="field" name="b[optional_field_{$i}][]" >
	{foreach $field.dropdown as $val}
		{if $val.value}
			<option value="{$val.value|escape}" {if $val.selected} selected {/if} /> {$val.value}</option>
		{/if}
	{/foreach}
       </select>

The above isn't the only way but something that will work. The section section of code found is for the category specific questions that have dropdowns attached and looks like this:

<ul>
	{foreach $q.options as $opt}
		{if $opt}
			<li><label><input type="checkbox" name="b[question_value][{$q.key}][]" value="{$opt|escape}" /> {$opt}</label></li>
		{/if}
	{/foreach}
</ul>

And you would replace the above with something like that below to make it use a dropdown:

<select class="field" name="b[question_value][{$q.key}][]">
	{foreach $q.options as $opt}
		{if $opt}
			<option value="{$opt|escape}" /> {$opt}</option>
		{/if}
	{/foreach}
</select>

The above suggestions should get you started at least.

To emphasize the point changes like these are beyond the scope of support that we provide through our support staff. If you can temporarily remove the use of your system template (renaming it) and the base registration form works with the default template in use your changes would be the problems if there are any issues when your custom template is in use. If ours default template works and your custom template doesn't you're beyond support our support staff can provide. If you need help from Geodesic you would need to purchase developer time through sales or consult with an external developer familiar with html and Smarty code.

tutorials/design_adv/examples/checkbox_to_dropdown_in_search.txt · Last modified: 2014/09/25 16:55 (external edit)