Super Search 3.x

Legacy documentation for Super Search 3.x.

Super_Search:Save_Search_Form template tag

The Super_Search:Save_Search_Form tag allows your users to save their searches. Once a user has completed a search, they have the option to save the search and give it a name of their choice. These saved searches are then available to see using the Super_Search:History tag.

Typically, you would be placing this tag on your search results page (outside of the Super_Search:Results loop) to allow users to save their search queries.

{exp:super_search:save_search_form} content {/exp:super_search:save_search_form}

Parameters

The following parameters are available for use:

delete_mode

delete_mode="yes"

This parameter switches the form to operate in Delete mode. When you submit the form in Delete mode, the given search identified by the search_id parameter is deleted from your history.

form:attribute=

form:class="your_class"

This parameter allows you to control any form attribute for the form in your template. Simply replace attribute with an attribute name such as id, name, class, etc, and specify a value for that attribute. You can specify this parameter multiple times to control as many attributes as necessary. This would normally be done to control your form with Javascript or style it with CSS.

onsubmit=

onsubmit="some_javascript_function();"

This parameter allows you to indicate an onsubmit action for your form.

return

return="template_group/template_name"

This parameter determines where to send users once they have submitted the form.

search_id=

search_id="{segment_3}"

You can load a search ID into this parameter to allow someone to edit the name they have given to one of their searches. If no search ID is provided in this parameter, the form will fetch the last search the user executed, thus allowing them to provide a name for the search, submit the form, and add that most recent search to their search history. If the current user is NOT a logged in member (Guest), Super Search changes to cookie based identification, and the searches are saved that way.

Variables

The following variables are available for use:

super_search_date

{super_search_date format="%l, %F %j, %Y at %g:%i %a"}

This variable will output the date of when the search was performed.

super_search_name

{super_search_name}

This variable will output the name given to the search. Defaults to Search if a name has not yet been given to the search.

super_search_results

{super_search_results}

This variable will output the total number of results in the search.

Examples

Saving a Search Query

The following sample code is a basic example of how your Search Results page might look with the Save_Search_Form tag implemented in order to save searches to a users’ history:

{exp:super_search:save_search_form}
    <p>
        <label for="super_search_name">Save this Search?<label>
        <input
            type="text"
            name="super_search_name"
            id="super_search_name"
            value="{super_search_name}" />
        <input type="submit" name="submit" value="Save!" />
    </p>
{/exp:super_search:save_search_form}

{exp:super_search:results}
    <div class="search_result">
        <h3>{title}</h3>
        <p>Price: ${price}</p>
        <p>{excerpt}</p>
    </div>
    {if super_search_no_results}
        No results matched your query.
    {/if}
{/exp:super_search:results}

Edit a Saved Search Query

Below is an example of how you would use the Save_Search_Form tag to edit the names of existing saved searches, assuming you have the search ID in the 3rd segment of the URI:

{exp:super_search:save_search_form
    return="supersearch/save_search_form"
    search_id="{segment_3}"
}
    <h3>Edit this Search?</h3>
    <p><input type="text" name="super_search_name" value="{super_search_name}" /></p>
    <p><input type="submit" name="submit" value="Save!" /></p>
{/exp:super_search:save_search_form}

Delete a Saved Search Query

Below is an example of how you would use the Save_Search_Form tag to delete existing saved searches, assuming you have the search ID in the 3rd segment of the URI:

{exp:super_search:save_search_form
    return="supersearch/history"
    search_id="{segment_3}"
    delete_mode="yes"
}
    <h3>Are you sure you want to Delete the Search named "{super_search_name}"?</h3>
    <p><input type="submit" name="submit" value="Yes, Delete" /></p>
{/exp:super_search:save_search_form}