Search function for ProcessWire

How to achieve a search function for ProcessWire just like here by using only one template file with some lines of PHP? This template is also included in my site profile which I offer here.

Download the files
The download is available at the end of this page.

Upload the files
Extract all files and upload the PHP-file into site/templates/. Upload the CSS-file and the search.png into site/templates/styles/ or in another directory you prefer for CSS-files. Please remember, that you have to link this CSS-file in your markup (_main.php) by yourself.

Install the templates
Go to Setup->Templates and click "Add New".

Add NewNow you will see the simple-search template file which you just uploaded into site/templates/. Set the checkmark on this file and click on "Duplicate fields used by another template". In the list below choose "home". Now click on "Add Template".

Add Template

Create the Search Page
Go to the "Pages". Moving the cursor over the page name (e.g. "Home") will bring up some options. Click on "New".

Click on New.Select as template "simple-search", enter a title e.g.: "Search Page" and click "Save". On the next page click "Publish".

Click: SaveNow you can link this "search-page" in your navigation and open it. The result can be tested also here.



Change log:

  • Version 1.0: Initial version
  • Version 2.0: Some improvements
Published: 29. Jan 2020
Categories: ProcessWire CMS PHP