Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/refinery/refinerycms-settings
Extracted from Refinery CMS
https://github.com/refinery/refinerycms-settings
Last synced: 3 months ago
JSON representation
Extracted from Refinery CMS
- Host: GitHub
- URL: https://github.com/refinery/refinerycms-settings
- Owner: refinery
- License: mit
- Created: 2012-02-23T10:31:14.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2022-03-04T04:40:18.000Z (over 2 years ago)
- Last Synced: 2024-05-12T18:38:05.108Z (6 months ago)
- Language: Ruby
- Homepage: http://refinerycms.com
- Size: 141 KB
- Stars: 26
- Watchers: 11
- Forks: 48
- Open Issues: 6
-
Metadata Files:
- Readme: readme.md
- License: license.md
Awesome Lists containing this project
- awesome-refinerycms - refinerycms-settings - Change settings in the backoffice (Refinery team extensions / Backoffice extensions)
README
# Refinery CMS Settings
[![Build Status](https://travis-ci.org/refinery/refinerycms-settings.svg?branch=master)](https://travis-ci.org/refinery/refinerycms-settings)
## About
Refinery Settings was extracted from Refinery CMS just before 2.0.0 was released
and can now be used separately.## Installation
Add the gem to you Gemfile:gem 'refinerycms-settings'
Generate and install the necessary migrations:
rails generate refinery:settings
rake db:migrate## Upgrading from 2.0.x
When you upgrade from version 2.0.x make sure you run:rails generate refinery:settings
rake db:migrateIt will copy the new migration and migrate the database.
## How do I Make my Own Settings?
### In view
Settings can be really useful, especially when you have custom display logic or
new plugins that need to behave in different ways.To best explain how settings work, let's use an example. Say you have a client
who has a display in a local trade show every year and 2 months before the trade
show, they want to display a little banner in the header of all pages.Once the trade show is finished, the client needs to be able to hide it again
until next year. This is what your ``application.html.erb`` file might look like:...
My Company
<% if ::Refinery::Setting.find_or_set(:show_trade_show_banner, false) %>
<%= image_tag ('trade-show-banner.jpg') %>
<% end %>
...The following will automatically create a new Refinery setting called
"show_trade_show_banner" and set its default to ``false``.
If that setting already exists, it just reads in what the current value is.So as you can see, this is quite clever because you can quickly define new settings
and their defaults right from the view as you need them.This setting would then show up in the backend in the 'Settings' area where the
client could change the value as their trade show approaches. Easy as pie!### In Controller
limit = Refinery::Setting.find_or_set(:list_limit, 20)