Search Page clear GET params on re-submit


(James Porich) #1

Matrix Version: 5.3.4.0

Hi guys,

I’ve got a Search Page set up which is working fine. It searches assets under a rootnode and checks if their metadata meets certain criteria then spits them out if they do.

I’ve currently got an issue however where after my results, I allow the user to search again - however this is currently functioning like the Search within Search functionality where the GET parameters are being added to the initial search, rather than performing a fresh search. I’m not sure how/why this is as I actually want a completely new search every time rather than an “additive” search.

Just wondering how I can make it so when users use the submit button it always performs a fresh search with only the GET parameters they select that particular search.

Current code looks like so:

<fieldset>

    <p>
        <h3>Search by field:</h3><br>
        
        
        
        <label><input type="checkbox" name="queries_searchmed_query" value="medical"  id="queries_searchmed_query" class="sq-form-field unstyled" />
            Medical
        </label>
		<label><input type="checkbox" name="queries_searchdent_query" value="Dental"  id="queries_searchdental_query" class="sq-form-field unstyled" />
		   Dental
		</label>
		<label><input type="checkbox" name="queries_searchbio_query" value="BiomedicalSciences" id="queries_searchbio_query" class="sq-form-field unstyled" />
		    Biomedical
		</label>
		<label><input type="checkbox" name="queries_searchpsych_query" value="PsychologicalSciences" id="queries_searchpsych_query" class="sq-form-field unstyled" />
		    Psychological
		</label>
	
    </p>
    
    
</fieldset>

<p class="center">
    %submit_button%
</p>

This search form body copy is embedded again after the results are printed out.

Note: I’ve opted for hard code rather than keywords so I could use checkboxes as users are only search for specific values and a freeform text field isn’t really what we’re after - this may be an issue but I figured that it should function the same as a text input field as we’re still passing the same values.

Is this solution maybe better handled with a straight asset list or something similar rather than a search page?


(Bart Banda) #2

Yep, this is the reason why. If you hard code search fields instead of using the keywords, Matrix will not know about it and will have to print the custom post values as hidden HTML input fields on the results page (check view source on the results page and you will see them).

One alternative is to use some JS to remove those hidden input fields on the results page?