Skip to content
Newer
Older
100644 61 lines (36 sloc) 2.37 KB
45ec12c Added Readme
Amanda Nicholas authored
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
86e8f9f @joemsak Give credit to the gem and point people there for more info & help on…
joemsak authored
6 Powered by: [acts_as_indexed](http://github.com/dougal/acts_as_indexed) - Check his readme and documentation for more info on how it works.
7
a8e679d @parndt Converted to a Rails3/Refinery CMS engine.
parndt authored
8 ## Installation
45ec12c Added Readme
Amanda Nicholas authored
9
a8e679d @parndt Converted to a Rails3/Refinery CMS engine.
parndt authored
10 Simply use this by adding the following to your ``Gemfile``:
45ec12c Added Readme
Amanda Nicholas authored
11
a8e679d @parndt Converted to a Rails3/Refinery CMS engine.
parndt authored
12 gem 'refinerycms-search', '~> 0.9.8'
45ec12c Added Readme
Amanda Nicholas authored
13
a8e679d @parndt Converted to a Rails3/Refinery CMS engine.
parndt authored
14 You'll also need to create a page (from the 'Pages' tab) with a custom URL of '/search'.
15 You can set a custom URL for a page in the Advanced Options.
16 It's probably also a good idea to uncheck the 'show in menu' option for this page.
45ec12c Added Readme
Amanda Nicholas authored
17
14c27f3 @joemsak Helpful tips in the README
joemsak authored
18 ## Restart your web server and RE-SAVE all the freshly indexed records.
284cb30 @joemsak README updated with a couple of friendly reminders
joemsak authored
19
ccc7697 @joemsak It /does/ matter that this link is broken, thanks captproton
joemsak authored
20 A sample search form can be found in [views/shared/_search.html.erb](http://github.com/resolve/refinerycms-search/blob/master/app/views/shared/_search.html.erb).
a8e679d @parndt Converted to a Rails3/Refinery CMS engine.
parndt authored
21 You can either use this partial directly, or copy the appropriate parts.
45ec12c Added Readme
Amanda Nicholas authored
22
a8e679d @parndt Converted to a Rails3/Refinery CMS engine.
parndt authored
23 ## Searching
45ec12c Added Readme
Amanda Nicholas authored
24
25a5024 @parndt Let's try a different approach which is far more likely to work :-)
parndt authored
25 The default installation will search in Pages.
26 If you wish to find results in other plugins you have created or installed, you can specify these in ``config/application.rb`` like so:
45ec12c Added Readme
Amanda Nicholas authored
27
25a5024 @parndt Let's try a different approach which is far more likely to work :-)
parndt authored
28 config.to_prepare do
29 Refinery.searchable_models = [Page]
30 end
45ec12c Added Readme
Amanda Nicholas authored
31
32 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:
33
25a5024 @parndt Let's try a different approach which is far more likely to work :-)
parndt authored
34 config.to_prepare do
35 Refinery.searchable_models = [Page, PortfolioEntry]
36 end
eed054b @joemsak These changes help it work in Rails3 RefineryCMS acceptably.
joemsak authored
37
14c27f3 @joemsak Helpful tips in the README
joemsak authored
38 The above line will add indexing to PortfolioEntry in the portfolio plugin, which does not come indexed.
39
a8e679d @parndt Converted to a Rails3/Refinery CMS engine.
parndt authored
40 Any model you wish to search will need to be indexed using acts as indexed. To add indexing, simple add:
45ec12c Added Readme
Amanda Nicholas authored
41
0b7ded1 @awagener Corrected format of sample call to acts_as_indexed
awagener authored
42 acts_as_indexed :fields => [:title, :body]
45ec12c Added Readme
Amanda Nicholas authored
43
14c27f3 @joemsak Helpful tips in the README
joemsak authored
44 If your model doesn't use a ``:title`` attribute, remember to add an ``alias_attribute``:
284cb30 @joemsak README updated with a couple of friendly reminders
joemsak authored
45
46 alias_attribute :title, :name #for example
47
14c27f3 @joemsak Helpful tips in the README
joemsak authored
48 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.
25a5024 @parndt Let's try a different approach which is far more likely to work :-)
parndt authored
49
c1873c7 @joemsak I don't know how to preview multi markdown pages before pushing.
joemsak authored
50 acts_as_indexed :fields => [:name, :biography]
25a5024 @parndt Let's try a different approach which is far more likely to work :-)
parndt authored
51
c1873c7 @joemsak I don't know how to preview multi markdown pages before pushing.
joemsak authored
52 #...
25a5024 @parndt Let's try a different approach which is far more likely to work :-)
parndt authored
53
c1873c7 @joemsak I don't know how to preview multi markdown pages before pushing.
joemsak authored
54 def name
55 (first_name, last_name).compact.join(' ')
56 end
14c27f3 @joemsak Helpful tips in the README
joemsak authored
57
a8e679d @parndt Converted to a Rails3/Refinery CMS engine.
parndt authored
58 You will need to replace the indexed fields with those appropriate for your model.
14c27f3 @joemsak Helpful tips in the README
joemsak authored
59
eed054b @joemsak These changes help it work in Rails3 RefineryCMS acceptably.
joemsak authored
60
a8e679d @parndt Converted to a Rails3/Refinery CMS engine.
parndt authored
61 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.