Sha256: 83f5c2ab2bdd30e5e29480d28a4e3c718e9d6075b47f67d1b389ec6fcfb7338b
Contents?: true
Size: 1.48 KB
Versions: 2
Compression:
Stored size: 1.48 KB
Contents
# LocomotiveCMS search ## Setup Open your _Gemfile_ and add locomotive-cms search to it: gem 'locomotivecms-search', require: false Run `bundle install`, then edit config/initializers/locomotive.rb and add this line: require 'locomotive/search/mongoid Check out the Activesearch gem to know which backends are available and how to configure them. ## Adding the search results page Create a new page that will display your search results. Its code might be something like this: {% for result in site.search %} <li><a href="/{{result.slug}}">{{ result.title }}</a></li> {% endfor %} As you can see, when a search string is passed in the URL, you can fetch the results by using `site.search`. Choose a good __slug__, like "search". ## Adding the search form Anywhere on your site you can add a simple form to fire a search. This could be done on the homepage, on a page you are inheriting from, on even on a snippet. Just add this code: <form action="/{{ locale }}/search" method="GET"> <label for="search">Search</label> <input type="text" name="search" id="search"> <input type="submit" value="Search"> </form> The important part is the action parameter, since __it must point to the slug of your search results page__. Also, the name of the search input must be "search". ## Note for mongoid 2.x users If you are using the mongoid engine and still on 2.x, you must use locomotivecms-search version ~> 0.0.5 This project rocks and uses MIT-LICENSE.
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
locomotivecms-search-0.2.1 | README.md |
locomotivecms-search-0.2.0 | README.md |