#97

Product support

Visit this product's website for support.

Categories

  • Miscellaneous
  • Utility

This plugin is an extension to the RainLab.Blog plugin. With this extension you can simply search the blog posts' title and content and display the search results

Components

This Plugins just has two simple Components to output a simple search form and display search results

Search results with search form in the sidebar

Search Form

The searchForm component outputs a simple search form to search your posts.

  • Search Results Page - Specify the page where you display the search results (the page with the searchResult component)

Search Results

The searchResults component returns all posts that match the search term from the search form.

  • Search Term - The URL parameter defining the search term.
  • Page number - The URL parameter defining the page number.
  • disableUrlMapping - If the url Mapping is disabled the search form uses the default GET Parameter search (e.g. example.com/search?search=Foo instead of example.com/search/Foo)
  • Hightlight Matches - Wrap the search terms found in the posts with <mark>-Tags or not
  • Posts per page - Number of posts to display per page.
  • No Posts Message - Message to show if no posts where found.
  • Sort Order - The order in which the posts are sorted.
  • Include Categories - 'Only Posts with selected categories are included in the search result
  • Exclude Categories - Specify which categories you want to exclude from your search results, so posts with them don't show up in the results.
  • Category Page - The page where the blog posts are filtered by a category.
  • Post Page - The page where single blog posts are displayed.

Documentation

Example Usage of Components

title = "Search Result"
url = "/blog/search/:search?/:page?"
... other stuff

[searchResult]
searchTerm = "{{ :search }}"
pageNumber = "{{ :page }}"
hightlight = 1
postsPerPage = 10
noPostsMessage = "No posts found"
sortOrder = "published_at desc"
excludeCategories[] = 1
excludeCategories[] = 2
excludeCategories[] = 3
categoryPage = "blog"
postPage = "blog/posts"

[searchForm]
resultPage = "blog/search"
categoryFilter = 0
==
<div class="container">
    <div class="row">
        <div class="page-header">
            <h2>Blog Search</h2>
        </div>
        <div class="col-sm-8">{% component 'searchResult' %}</div>
        <div class="col-sm-4">{% component 'searchForm' %}</div>
    </div>
</div>

Exclude/Include Categories

In order to exclude/include more than one category you need OctoberCMS Build >= 306 which brings the new Inspector Feature

  • Found the plugin useful on 13 Apr, 2016

    Yes please add support for regular URL query parameters. I'm getting a problem because of that when the user empties the search input. Then the URL parameter will not be removed, but instead the empty URL query parameter gets attached:

    URL pattern > blog/:search URL after search submit: blog/searchterm URL after emptying search input and submit: blog/searchterm?search=

  • author

    Replied on 18 Apr, 2016

    Hi, sorry for the late response. Since version 1.2.0 it is possible to use the regular query parameters. In the searchResult component just activate the Disable URL Mapping option and remove the :search part from the url pattern.

    Example URL pattern: /blog/search/:page? -> after search submit: /blog/search?search=hello

  • Found the plugin useful on 10 Mar, 2016

    Is there some possibility to have search parameter as GET? Like website.com/search?q=test?

    I tried to set searchTerm = &quot;{{ q }}&quot; but it doesn't work.

  • author

    Replied on 12 Mar, 2016

    Hi, the plugin uses GET requests, but it maps all requests from website.com/search?q=test to something like website.com/search/test if your url schema is website.com/search/{searchterm}.

    I could add an option to disable that in the next version :)

  • Found the plugin useful on 17 Jul, 2015

    Definitely nice to have a search functionality added to Rainlab.Blog without having to deal with implementing it myself amidst the rest of a project. Some tweaks were required after initial inclusion in project(pagination issues, resolved with workaround but not entirely as of yet, but am hopeful!), but the plugin Author is readily helpful in problem solving and issue troubleshooting. I suspect this plugin will have a number of projects attached to it before long.

1.3.0

!!! Removed support for old Inspector Features prior to October 306

Aug 01, 2016

1.2.3

Fixed bug which caused included/excluded categories not being saved

Apr 01, 2016

1.2.2

optimized query for included/excluded categories

Mar 21, 2016

1.2.1

fixed bug with missing categories

Mar 14, 2016

1.2.0

added option to show only results from selected categories

Mar 14, 2016

1.1.1

remove '?' from url if query is empty

Feb 07, 2016

1.1.0

added category filter

Oct 26, 2015

1.0.6

included `excerpt` into search

Aug 20, 2015

1.0.5

fixed wrong routing

Jul 17, 2015

1.0.4

Replaced POST Method with GET

Jul 17, 2015

1.0.3

Removed _ filter because it caused to much problems when Translate Plugin is missing

Jul 10, 2015

1.0.2

Fixed error with missing Translate Plugin

Jul 10, 2015

1.0.1

First version of Blog Search

Jul 10, 2015

With Version 1.3.0 you need to have at least October version 306. Otherwise the plugin won't work