Demo of Search Widget and WP REST Server for Toolset Types

Further development of this plugin has been discontinued. However, the existing feature set of this plugin will be supported for the forseeable future.

This search widget can search Toolset Types custom post types by the values of Toolset Types custom fields and taxonomy. In addition this search widget can also specify search criteria for child of/parent of relationships, post content, post excerpt, post title and post author. The widget uses user friendly substitutions for the actual values in the database, e.g. post title is substituted for post id in child/parent fields. In the “Single-Page Application” mode the search widget in the sidebar is used to interactively load the contents of the search results pane below.


Search Results

This pane shows the results of the Search widget in the sidebar.
The shortcode 'stcfw_inline_search_results' is only valid in Backbone.js with Bootstrap mode.

This example uses un-edited auto-generated (available from version 2.2.1) user defined templates to customized the table view.

Single-Page Application vs Traditional WordPress

In traditional WordPress when the user makes a request the browser loads a whole new page even if most of the content is still the same. In the single-page application mode above the browser makes an AJAX request to populate a (Backbone.js) JavaScript model which is then used to instantiate (using a Underscore.js template) a HTML view which refreshes a pane in the page. I think this new paradigm is more efficient, more responsive, more user friendly, more flexible, … than loading a whole new page on every request. This search widget is just an example but much more is possible which is why I am implementing a REST server for Toolset Types custom posts.

The REST Server

This demo is of version which includes support for a WP REST server for Toolset Types custom fields. You can run the curl commands below on this server.

Get by post id:

Search by Toolset Types checkboxes custom field:
curl -g "[]=glacial&lake-type[]=crater"

Search by Toolset Types checkbox custom field:

Search by Toolset Types radio custom field:

Search by Toolset Types select custom field:

Search by Toolset Types taxonomy field:

Search by Toolset Types single line custom field:

Search on compound conditions:
curl -g ""

Of course you can do the usual WordPress search:

Search on parent/child relationships:

The JavaScript Client

Version includes a JavaScript client library derived from the WP REST API JavaScript Client Library. This client library makes it easy to fetch a collection of Toolset Types custom posts, e.g.

var collection = new mcst.api.collections.Lakes();
collection.fetch( {
    data: { "lake-type": "salt" },
    success: function( collection, response, options ) {
        console.log( collection );
    error: function( collection, response, options ) {
        alert( "fetch() failed." );
} );

I have written a minimal application using this client library. You can use the search widget above to find appropriate values for the fields. For checkbox fields (e.g., endorheic) the appropriate values are true or false – not the pretty labels. N.B., this uses version of this plugin which can be downloaded from GitHub.

Try it yourself

Version can be downloaded from GitHub. The documentation for this plugin is here.