GithubHelp home page GithubHelp logo

refinerycms-search's Introduction

Search plugin for Refinery CMS

Powered by: acts_as_indexed - Check his readme and documentation for more info on how it works.

Installation

Simply use this by adding the following to your Gemfile:

gem 'refinerycms-search', '~> 2.0.0'

Now, run bundle install

Next, to install the search plugin run:

rails generate refinery:search

Run database migrations:

rake db:migrate

Finally seed your database and you're done.

rake db:seed

RE-SAVE all records that have not been indexed before.

A sample search form can be found in views/refinery/shared/_search.html.erb. You can either use this partial directly, or copy the appropriate parts.

Searching

The default installation will search in Pages. If you wish to find results in other plugins you have created or installed, you can specify these in config/application.rb like so:

config.to_prepare do
  Refinery.searchable_models = [Refinery::Page]
end

Simply add any additional models you wish to search to this array. For example, if you have the portfolio plugin installed:

config.to_prepare do
  Refinery.searchable_models = [Refinery::Page, Refinery::PortfolioEntry]
end

The above line will add indexing to PortfolioEntry in the portfolio plugin, which does not come indexed.

Any model you wish to search will need to be indexed using acts as indexed. To add indexing, simple add:

acts_as_indexed :fields => [:title, :body]

If your model doesn't use a :title attribute, remember to add an alias_attribute:

alias_attribute :title, :name #for example

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.

acts_as_indexed :fields => [:name, :biography]

#...

def name
  [first_name, last_name].reject(&:blank?).join(' ')
end

You will need to replace the indexed fields with those appropriate for your model.

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.

refinerycms-search's People

Contributors

ugisozols avatar parndt avatar joemsak avatar awagener avatar chrisftw avatar diamondap avatar adamico avatar matho avatar djones avatar dmoose avatar mamedov avatar mhaylock avatar markprovan avatar mirosr avatar nickurban avatar robyurkowski avatar snowsunny avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.