Search Magic Fields 2 Widget 0.5.3

The current version 0.5.3 requires some features from my toolkit and is only distributed as part of the toolkit.

This search widget can search for Magic Fields 2 custom posts, WordPress posts and pages by the value of Magic Fields 2 custom fields, WordPress taxonomies and post content. It is designed to be used with Magic Fields 2 only and makes use of Magic Fields 2’s proprietary database format to generate user friendly field names and field values. The widget uses user friendly substitutions for the actual values in the database when appropriate, e.g. post title is substituted for post id in related type custom fields. Version 0.4.2 lets the user select whether the search criteria are joined by an AND or a OR operator.

What is new in 0.5.3

Version 0.5.3 supports post type specific search result templates.

What is new in 0.4.6

The search result table of posts will be a sortable table. This upgrade requires you to manually upgrade the search widget’s content macro by restoring the current default content macro by erasing the content macro definition.

What is new in 0.4.5.3

The pagination bug on search results is fixed. It is now possible to search by post author. The alternate search results output can now be styled using a post type specific css file. If there is only one post type the step to select post type is omitted.

What is new in 0.4.5

Version 0.4.5 supports displaying the search results using excerpts instead of the full post and displaying the search results using a Magic Fields 2 Toolkit content macro. This can show the search results as a table of posts – one row per post. The order of fields can now be changed by drag and drop.

Download

This widget is a feature of the Magic Fields 2 Toolkit which can be downloaded from the WordPress.org repository.

How to Use this Widget

The widget has two parts: an administrator part that the administrator uses to select the post types and custom fields that the user will be allowed to search and a user part that the user uses to select the post type, custom fields and custom field values for the search.

The Administrator’s Interface

fields
The administrator’s interface is use to select the post types and the fields that the user will be able to search. If no fields are selected for a post type then the user will not be allowed to search that post type. The fields include custom fields, taxonomy fields and post content. A search of the post content includes the post title and the post excerpt. In this example the user is allowed to search for engines by year, manufacturer and/or displacement. The number in parenthesis for post types is the number of posts of that type. The number in parenthesis for fields is the number of posts which have values for that field. The second column of checkboxes is used only if the option to display search results using a content macro is enabled and selects the fields to be displayed by the content macro. You can change the order of the fields by drag and drop.


Widget SettingsFrom version 0.4.5 the administrator can set options to configure how the widget is displayed and how the search results are displayed.

Maximum number of items to display per custom field:The items are selected by descending frequency.

Display search results using the same template as the default WordPress search: If this option is enabled the search results are displayed using the same template as the built-in WordPress search. Depending on your theme this may show excerpts instead of the the full post.

Enable option to display search results using a content macro: If this option is enabled the user is allowed to choose to display the search result in an alternate format specified by a Magic Fields 2 Toolkit content macro.

The content macro to use to display the search results: This is a Magic Fields 2 Toolkit content macro used to display the search results. The default content macro displays the search result as a table of posts – one row per post. The content macro is given 4 parameters: posts – a list of post ids, a_post – the first post id, fields – a list of fields and post_type – the post type.


If you have edited the content macro you can restore the default content macro by completely erasing the content macro. Erasing the content macro will also upgrade the content macro to the current default content macro. This may be necessary after an upgrade since an upgrade will not automatically replace an existing content macro – because you may have customized it.


From version 0.4.5.3 the alternate search results display output can be styled by providing a post type specific css file – search-results-table-posttype.css – where posttype is the slug of the post type. This file should be put in the plugin’s folder – …wp-content/plugins/magic-fields-2-toolkit/. The easiest way to do this is by coping and modifying the default css file – search-results-table.css. Usually you will want to change the table width. From version 0.4.6.2 the search widget itself can be styled by editing the css file ‘search.css’ in the plugin’s folder.

From version 0.5.3 you can define a post type specific content template (formerly called a content macro). The administrator’s interface provides a tool to generate a basic content template for the post type. The generated content template is saved as a content template which can be edited to further customize it.

The User’s Interface

search1
The user first selects the post type that he wants to search. The server will then return a search form for the selected post type. The number in parenthesis is the number of posts of that type.


search2

The user then specifies the search conditions by selecting values for some of the fields for the posts he is searching for. If more than one value is selected for a single field then a post with either value satisfies that search condition. If more than one field is selected then a post must satisfy all search conditions. In this example the user is searching for carburetors manufactured in 1970 with 4 barrels. The numbers in parenthesis is the number of items with that value. If a field has more than 16 distinct values the most frequent 16 values are displayed with checkboxes and an optional textbox is displayed where the user can manually input the search value.


optionsThe user can specify whether to AND or OR the conditions. If the option to display search results using a content macro was enabled by the administrator then the “Show search results in alternate format:” checkbox is displayed. The default alternate format is a sortable table of posts – one row per post. table

How to report problems, ask questions, …


Please post your problem reports, questions, requests and comments to the Magic Fields 2 Toolkit Support Forum.