{livesearch:view_param:placeholder:default_phrase}

Description

Renders a live search widget on the page - a search input plus a results list that refreshes as the visitor types. The first parameter is the AA view that produces the results; the typed phrase is passed into that view as the search term, so each keystroke re-runs the view and updates the list. Pass a bare view id and the phrase is matched against the views first condition automatically; pass full view parameters and mark where the phrase goes with the AA_LS_QUERY placeholder. The optional second parameter sets the search fields placeholder text, the third sets a default phrase searched when the field is empty (use a single dash to start with an empty list). Requires jQuery and aajslib-jquery. The output is HTML and JavaScript generated fresh on every request, so it is never cached and the examples below are illustrative rather than fixed test values.

Parameters

view_param required

The AA view that produces the results, given as a bare view id or as full view parameters. A bare numeric id is auto-wrapped so the typed phrase is matched against the views first condition. With full view parameters, put the AA_LS_QUERY placeholder where the typed phrase should be substituted, e.g. 3650&cmd[3650]=c-1-AA_LS_QUERY-2-publications.

placeholder optional

Placeholder text shown inside the empty search field. Escaped for safe HTML output.

default_phrase optional

The phrase searched when the field is empty. Leave it out to show all results by default; set a single dash to start with an empty list (the widget then searches a sentinel value that matches nothing until the visitor types).

Examples

virtual{livesearch:3650::-}
Expected(a search widget for view 3650 with no placeholder text and an empty results list)
Actual
Just a view id (no placeholder). A bare numeric id is auto-wrapped so the typed phrase is matched against view 3650s first condition. The dash keeps the list empty until the visitor types.
virtual{livesearch:3650&cmd[3650]=c-1-%22AA_LS_QUERY%22-2-publications:Search publications...:-}
Expected(a search widget whose view call substitutes the typed phrase for AA_LS_QUERY in view 3650s condition 1, placeholdered Search publications...)
Actual
Full view parameters instead of a bare id. The AA_LS_QUERY placeholder marks where the typed phrase is substituted into the view conditions, here narrowing condition 1 of view 3650 within publications. Use this form when you need control over which field the phrase searches.
virtual{livesearch:3650:Search articles...:-}
Expected(a search widget: an article.aa-widget holding a search input placeholdered Search articles... and an empty itemgroup list, wired to view 3650)
Actual
View id with placeholder text. The trailing dash starts the results list empty until the visitor types; the typed phrase is matched against view 3650s first condition.