Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 55 lines (31 sloc) 2.187 kb
45ec12ca » Amanda Nicholas
2010-04-01 Added Readme
1 # Search plugin for [RefineryCMS](http://www.refinerycms.com)
2 [Github](http://github.com/resolve/refinerycms)
3
4 By: [Resolve Digital](http://www.resolvedigital.com)
5
a8e679d9 » parndt
2010-10-01 Converted to a Rails3/Refinery CMS engine.
6 ## Installation
45ec12ca » Amanda Nicholas
2010-04-01 Added Readme
7
a8e679d9 » parndt
2010-10-01 Converted to a Rails3/Refinery CMS engine.
8 Simply use this by adding the following to your ``Gemfile``:
45ec12ca » Amanda Nicholas
2010-04-01 Added Readme
9
a8e679d9 » parndt
2010-10-01 Converted to a Rails3/Refinery CMS engine.
10 gem 'refinerycms-search', '~> 0.9.8'
45ec12ca » Amanda Nicholas
2010-04-01 Added Readme
11
a8e679d9 » parndt
2010-10-01 Converted to a Rails3/Refinery CMS engine.
12 You'll also need to create a page (from the 'Pages' tab) with a custom URL of '/search'.
13 You can set a custom URL for a page in the Advanced Options.
14 It's probably also a good idea to uncheck the 'show in menu' option for this page.
45ec12ca » Amanda Nicholas
2010-04-01 Added Readme
15
14c27f36 » joemsak
2010-10-12 Helpful tips in the README
16 ## Restart your web server and RE-SAVE all the freshly indexed records.
284cb307 » joemsak
2010-07-22 README updated with a couple of friendly reminders
17
a8e679d9 » parndt
2010-10-01 Converted to a Rails3/Refinery CMS engine.
18 A sample search form can be found in [views/shared/_search.html.erb](http://github.com/blob/master/app/views/shared/_search.html.erb).
19 You can either use this partial directly, or copy the appropriate parts.
45ec12ca » Amanda Nicholas
2010-04-01 Added Readme
20
a8e679d9 » parndt
2010-10-01 Converted to a Rails3/Refinery CMS engine.
21 ## Searching
45ec12ca » Amanda Nicholas
2010-04-01 Added Readme
22
a8e679d9 » parndt
2010-10-01 Converted to a Rails3/Refinery CMS engine.
23 The default installation will search in Pages.
24 If you wish to find results in other plugins you have created or installed, you can specify these in ``config/settings.rb`` like so:
45ec12ca » Amanda Nicholas
2010-04-01 Added Readme
25
e2cae61c » awagener
2010-08-10 Update Readme
26 Refinery.searchable_models = [Page]
45ec12ca » Amanda Nicholas
2010-04-01 Added Readme
27
28 Simply add any additional models you wish to search to this array. For example, if you have the [portfolio plugin](http://github.com/resolve/refinerycms-portfolio) installed:
29
e2cae61c » awagener
2010-08-10 Update Readme
30 Refinery.searchable_models = [Page, PortfolioEntry]
eed054bd » joemsak
2010-09-30 These changes help it work in Rails3 RefineryCMS acceptably.
31
14c27f36 » joemsak
2010-10-12 Helpful tips in the README
32 The above line will add indexing to PortfolioEntry in the portfolio plugin, which does not come indexed.
33
a8e679d9 » parndt
2010-10-01 Converted to a Rails3/Refinery CMS engine.
34 Any model you wish to search will need to be indexed using acts as indexed. To add indexing, simple add:
45ec12ca » Amanda Nicholas
2010-04-01 Added Readme
35
0b7ded10 » awagener
2010-04-13 Corrected format of sample call to acts_as_indexed
36 acts_as_indexed :fields => [:title, :body]
45ec12ca » Amanda Nicholas
2010-04-01 Added Readme
37
14c27f36 » joemsak
2010-10-12 Helpful tips in the README
38 If your model doesn't use a ``:title`` attribute, remember to add an ``alias_attribute``:
284cb307 » joemsak
2010-07-22 README updated with a couple of friendly reminders
39
40 alias_attribute :title, :name #for example
41
14c27f36 » joemsak
2010-10-12 Helpful tips in the README
42 You can use any public method, as well. So if you have ``:first_name`` and ``:last_name`` but a method like ``name`` to join them, it can be indexed.
43
44 acts_as_indexed :fields => [:name, :biography]
45
46 #...
47
48 def name
49 (first_name, last_name).compact.join(' ')
50 end
51
a8e679d9 » parndt
2010-10-01 Converted to a Rails3/Refinery CMS engine.
52 You will need to replace the indexed fields with those appropriate for your model.
14c27f36 » joemsak
2010-10-12 Helpful tips in the README
53
eed054bd » joemsak
2010-09-30 These changes help it work in Rails3 RefineryCMS acceptably.
54
a8e679d9 » parndt
2010-10-01 Converted to a Rails3/Refinery CMS engine.
55 If you wish to override the url used in the search results just add a ``url`` method to your model and the result of this method will be used instead.
Something went wrong with that request. Please try again.