#22

Product support

Get help in the plugin support forum.

Categories

  • Miscellaneous
  • Utility

SiteSearch Plugin for October CMS

This plugin adds global search capabilities to October CMS.

Available languages

  • English
  • German
  • Czech
  • Russian
  • NEW! Persian (Farsi)
  • NEW! Portuguese

You can translate all contents into your own language.

Currently supported content types

Multilingual contents via RainLab.Translate are supported.

Support for more plugins is added upon request.

Get native support for your plugin

You can easily extend this plugin to search all your custom plugin's contents as well. See the documentation for further information.

If you are a plugin developer and wish to have native support for your contents in SiteSearch please submit a pull request for your search provider or send us a copy of you plugin so we can create the provider for you.

We cannot add support for every plugin but will add any plugin that has a notable project count on the October Marketplace.

Contributing

Translations, search providers, bug reports

Please submit pull requests with translations or search providers on the plugin's GitHub page. Bug reports and feature requests via Issues are welcome!

The following themes use this plugin:

Search results listing

Components

searchResults

Place this component on your page to display search results.

Usage example

Create a search form that sends a query to your search page:

Search form
<form action="{{ 'search' | page }}" method="get">
    <input name="q" type="text" placeholder="What are you looking for?" autocomplete="off">
    <button type="submit">Search</button>
</form>

Important: Use the q parameter to send the user's query.

Search results

Create a page to display your search results. Add the searchResults component to it. Use the searchResults.query parameter to display the user's search query.

title = "Search results"
url = "/search"
...

[searchResults]
resultsPerPage = 10
showProviderBadge = 1
noResultsMessage = "Your search did not return any results."
visitPageMessage = "Visit page"
==
<h2>Search results for {{ searchResults.query }}</h2>

{% component 'searchResults' %}
Overwrite default markup

It is highly recommended you overwrite the default markup of the search results component. This way your layout won't break when the plugin's default markup changes in future releases.

To overwrite the default markup copy all files from plugins/offline/sitesearch/components/searchresults to themes/your-theme/partials/searchResults and modify them as needed. The directory name is case sensitive.

[searchResults] // Place markup in /themes/your_theme/partials/searchResults
resultsPerPage = 10

If you gave an alias to the searchResults component make sure to put the markup in the appropriate partials directory.

[searchResults resultsAlias]  // Place markup in /themes/your_theme/partials/resultsAlias
resultsPerPage = 10
Example css to style the component
.ss-result {
    margin-bottom: 2em;
}
.ss-result__aside {
    float: right;
    margin-left: .5em;
}
.ss-result__title {
    font-weight: bold;
    margin-bottom: .5em;
}
.ss-result__badge {
    font-size: .7em;
    padding: .2em .5em;
    border-radius: 4px;
    margin-left: .75em;
    background: #eee;
    display: inline-block;
}
.ss-result__text {
    margin-bottom: .5em;
}
.ss-result__url {
}

Modify the query before searching

If you want to modify the user's search query before the search is executed you can call the forceQuery method on the searchResults component from your page's onStart method.

[searchResults]
resultsPerPage = 10
showProviderBadge = 1
noResultsMessage = "Your search returned no results."
visitPageMessage = "Visit page"
==
function onStart() {
    $query = Request::get('q');
    $query = str_replace('ё', 'e', $query);
    $this->page->components['searchResults']->forceQuery($query);
}
==
{% component 'searchResults' %}

Properties

The following properties are available to change the component's behaviour.

resultsPerPage

How many results to display on one page.

showProviderBadge

The search works by querying multiple providers (Pages, Blog, or other). If this option is enabled each search result is marked with a badge to show which provider returned the result.

This is useful if your site has many different entities (ex. teams, employees, pages, blog entries).

noResultsMessage

This message is shown if there are no results returned.

visitPageMessage

A link is placed below each search result. Use this property to change that link's text.

searchInput

Place this component anywhere you want to display a simple search input with "search as you type" capabilities.

Usage example

Add the searchInput component to any layout, partial or page.

title = &quot;Home&quot;
url = &quot;/&quot;
...

[searchInput]
useAutoComplete = 1
autoCompleteResultCount = 5
showProviderBadge = 1
searchPage = &quot;search.htm&quot;
==
{% component 'searchInput' %}
Example css to style the component
.ss-search-form {
    position: relative;
}
.ss-search-form__results {
    display: none;
    position: absolute;
    left: 0;
    top: 35px;
    width: 100%;
    background: #fff;
    padding: 1em;
    box-shadow: 0 2px 4px rgba(0, 0, 0, .1);
}
.ss-search-form__results--visible {
    display: block;
}

Properties

The following properties are available to change the component's behaviour.

useAutoComplete

If this property is enabled, a search query will be executed as soon as the user begins to type.

autoCompleteResultCount

This many results will be displayed to the user below the input field. There will be a "Show all results" link the user can click that takes her to a full search results page if one has been specified via the searchPage property.

showProviderBadge

The search works by querying multiple providers (Pages, Blog, or other). If this option is enabled each search result is marked with a badge to show which provider returned the result.

This is useful if your site has many different entities (ex. teams, employees, pages, blog entries).

searchPage

The filename of the page where you have placed a searchResults component. If a user clicks on the "Show all results" link it will take him to this page where a full search is run using the searchResults component.

Add support for custom plugin contents

Simple method

To return search results for you own custom plugin, register an event listener for the offline.sitesearch.query event in your plugin's boot method.

Return an array containing a provider string and results array. Each result must provide at least a title key.

Example to search for custom documents

See Readme on GitHub

Advanced method

If you need a bit more flexibility you can also create your own ResultsProvider class. Simply extend SiteSearch's ResultProvider and implement the needed methods. Have a look at the existing providers shipped by this plugin to get an idea of all the possibilities.

When your own ResultsProvider class is ready, register an event listener for the offline.sitesearch.extend event in your plugin's boot method. There you can return one ResultsProvider (or multiple in an array) which will be included every time a user runs a search on your website.

Advanced example to search for custom documents

See Readme on GitHub

Settings

You can manage all of this plugin's settings in the October CMS backend.

Rainlab.Pages

No special configuration is required.

Rainlab.Blog

Make sure you select your CMS page with the blogPost component as the blog post page in the backend settings.

You can access a post's published_at date in your search results via {{ result.meta }}.

Feegleweb.Octoshop

Make sure you set the Url of product detail page setting to point to the right url. Only specify the fixed part of the URL: /product. If your products are located under /product/:slug the default value is okay.

Jiri.JKShop

Make sure you set the Url of product detail page setting to point to the right url. Only specify the fixed part of the URL: /product. If your products are located under /product/:slug the default value is okay.

You can access an article's price in your search results via {{ result.meta }}.

Indikator.News

Make sure you set the News post page setting to point to the right url. Only specify the fixed part of the URL: /news/post. If your products are located under /news/post/:slug the default value is okay.

RadiantWeb.ProBlog

Make sure you set the Url of blog post page setting to point to the right url. Only specify the fixed part of the URL: /blog. If your posts are located under /blog/:category/:slug the default value is okay.

ArrizalAmin.Portfolio

Make sure you set the Url of portfolio detail page setting to point to the right url. Only specify the fixed part of the URL: /portfolio/project. If your detail page is located under /portfolio/project/:slug the default value is okay.

VojtaSvoboda.Brands

Make sure you set the Url of brand detail page setting to point to the right URL. Only specify the fixed part of the URL: /brand. If your brand detail page is located under /brand/:slug then insert only /brand without the slug parameter.

CMS pages (experimental)

If you want to provide search results for CMS pages change the enabled setting to On.

You have to specifically add the component siteSearchInclude to every CMS page you want to be searched. Pages without this component will not be searched.

Components on CMS pages will not be rendered. Use this provider only for simple html pages. All Twig syntax will be stripped out to prevent the leaking of source code to the search results.

CMS pages with dynamic URLs (like /page/:slug) won't be linked correctly from the search results listing.

If you have CMS pages with dynamic contents consider writing your own search provider (see Add support for custom plugin contents)

  • Found the plugin useful on 7 Oct, 2017

    Great plugin. Very extendable & works well with ProBlog. Love.

  • Found the plugin useful on 24 May, 2017

    First of all, thank you for this brilliant plugin. But i have a problem with images. It shows one image for all searched results, can you help me . TY

  • author

    Replied on 24 May, 2017

    Hi thanks for your review.

    Please use our GitHub issues page for any kind of support requests.

  • Found the plugin useful on 8 Mar, 2017

    Category insertion failed MySQL Server version: 5.7.17-0ubuntu0.16.04.1 (Ubuntu)

    "SQLSTATE[HY000]: General error: 1364 Field 'sort_order' doesn't have a default value (SQL: insert into `offline_snipcartshop_categories` (`name`, `slug`, `meta_title`, `meta_description`, `parent_id`, `nest_left`, `nest_right`, `updated_at`, `created_at`) values (Uncategorized, uncategorized, Uncategorized, , , 1, 2, 2017-03-08 20:07:20, 2017-03-08 20:07:20))" on line 662 of /var/www/html/seramik/vendor/laravel/framework/src/Illuminate/Database/Connection.php

  • author

    Replied on 8 Mar, 2017

    Hi

    Thanks for your review. I think you meant to review our SnipcartShop plugin, not this one.

    I have released a new version 1.0.6 to solve this problem. Another solution to work around this error is to turn off mysql strict mode for your installation.

  • Found the plugin useful on 30 Dec, 2016

    Hi is there a way to have auto-complete functionalities on this create plugin? Thanks Carl

  • author

    Replied on 31 Dec, 2016

    There is currently no support for autocomplete available. I have created an issue on github. Maybe we'll implement it in a future release. Thanks for your suggestion!

  • Found the plugin useful on 27 Nov, 2016

    Pretty awesome.

  • Found the plugin useful on 3 Jul, 2016

    Very good plugin and superb support! Thank you very much!

  • Found the plugin useful on 13 Feb, 2016

    This plugin works brilliantly.

    Great job - well done.

1.3.5

Added ability to edit the user's query before searching

Sep 19, 2017

1.3.4

Fixed undefined index error when a static page doesn't have a title set

Sep 10, 2017

1.3.3

!!! All results are now returned with a relative URL to prevent problems with translated contents. Make sure to pass your result.url throught the "app" filter if you are using your own search result partials

Sep 06, 2017

1.3.2

Fixed bug in AutoCompleteComponent

Jul 06, 2017

1.3.1

Added new searchInput component with search-as-you-type feature

Jun 27, 2017

1.2.33

Fix the use of multiple custom ResultsProvider for a plugin

Jun 25, 2017

1.2.32

Added support for custom ResultsProvider classes

Jun 24, 2017

1.2.31

Added model property for each search result to retreive the original model the result was generated from

Jun 22, 2017

1.2.30

The searchResults component's resultsCollection is now publically accessible

May 19, 2017

1.2.29

Optimized thumbnail generation for Graker.PhotoAlbums results (thanks to graker)

May 13, 2017

1.2.28

Added new result.identifier property

May 13, 2017

1.2.27

Added support for Graker.PhotoAlbums (thanks to graker)

May 12, 2017

1.2.26

Exclude hidden static pages from search results (thanks to plyusninva)

Apr 13, 2017

1.2.25

Fixed bug that sometimes lead to broken html in search results (thanks to graker)

Mar 14, 2017

1.2.24

Added composer.json to allow loading plugin as dependency (thanks to adduc)

Jan 03, 2017

1.2.23

Fixed support for translated Rainlab.Blog contents

Dec 14, 2016

1.2.22

Fixed Portuguese translations

Dec 14, 2016

1.2.21

Added Portuguese translations (thanks to ribsousa)

Dec 14, 2016

1.2.20

Added support for VojtaSvoboda.Brands (thanks to vojtasvoboda)

Dec 14, 2016

1.2.19

Added support for OFFLINE.SnipcartShop

Dec 04, 2016

1.2.18

Fixed bug where titles of static pages where not searched (thanks to beenen445)

Nov 15, 2016

1.2.17

Added support for Indikator.News (thanks to gergo85)

Oct 28, 2016

1.2.16

Added Persian (Farsi) translations (thanks to cracki)

Aug 28, 2016

1.2.15

Added a new meta property for search results (thanks to cracki)

Aug 27, 2016

1.2.14

Fixed bug in Jiri.JKShop provider

Aug 21, 2016

1.2.13

Minor bugfixes for marked queries in search results and Rainlab.Blog provider (Thanks to graker)

Aug 07, 2016

1.2.12

Added support for Jiri.Jkshop

Jul 24, 2016

1.2.11

Optimized handling of multibyte strings

Jul 10, 2016

1.2.10

Added support for multiple variables in Rainlab.Blog urls (Thanks to graker)

Jul 10, 2016

1.2.9

Added support for static page component hosts

Jul 06, 2016

1.2.8

Added support for viewBag properties in RainLab.Pages

Jul 05, 2016

1.2.7

Fixed bug where custom url settings were ignored in search results for some providers

Jul 04, 2016

1.2.6

Added support for Responsiv.Showcase (Thanks to MichiReich)

Jul 04, 2016

1.2.5

Fixed bug where the provider badge is not displayed for custom search providers

Jun 29, 2016

1.2.4

Fixed bug where unavailable thumbnails lead to an error

Jun 27, 2016

1.2.3

Fixed bug where the search results sometimes broke the page layout

Jun 16, 2016

1.2.2

Minor bugfix in Feegleweb.Octoshop settings page translation

May 31, 2016

1.2.1

Added support for Feegleweb.Octoshop (Thanks to billyzduke)

May 27, 2016

1.1.3

Added ru_RU locale (Thanks to mokeev1995)

May 24, 2016

1.1.2

Fixed backend permissions

May 21, 2016

1.1.1

Added optimized siteSearchInclude component for cms pages search

May 21, 2016

1.1.0

Added support for translated contents in RainLab.Pages, ArrizalAmin.Portfolio and RadiantWeb.ProBlog

May 21, 2016

1.0.10

Removed unused component

Apr 26, 2016

1.0.9

Added support for ArrizalAmin.Portfolio plugin

Apr 21, 2016

1.0.8

Add cs_CZ locale (Thanks to vojtasvoboda)

Apr 03, 2016

1.0.7

Add function for getting last page number (Thanks to vojtasvoboda)

Mar 21, 2016

1.0.6

Fixed hardcoded url in pagination

Feb 21, 2016

1.0.5

Moved configuration to the backend

Feb 13, 2016

1.0.4

Added support for RadiantWeb.ProBlog

Feb 13, 2016

1.0.3

Added missing component

Feb 10, 2016

1.0.2

Added experimental CMS pages results provider

Feb 09, 2016

1.0.1

First version of SiteSearch

Jan 30, 2016

Upgrade to version 1.0.5

All configuration has been moved to the backend settings. If upgrading from a lower version don't forget to enter your configuration again via the backend.

Upgrade to version 1.3.3

If a plugin returned an absolute url (http://example.com/result) for a result this will now be converted to a relative url (/result) so make sure you are passing the result.url through the app filter in your partials.

This is to prevent problems with Rainlab.Translate where sometimes the language was present twice in the url when using the Force url scheme option.

If you are using the default search result partials you don't need to change anything.

<p class="ss-result__url">
    <a href="{{ result.url | app }}" class="ss-result__link">{{ __SELF__.visitPageMessage }} →</a>
</p>