Created
December 10, 2015 05:54
-
-
Save joebrislin/4371636194572dc8f5b2 to your computer and use it in GitHub Desktop.
Code Samples - Case Studies Extension for Marketing Website (Refinery CMS)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Refinery | |
module Casestudies | |
class CasestudiesController < ::ApplicationController | |
layout :selectLayout | |
before_action :find_all_casestudies | |
before_action :find_page | |
def index | |
# you can use meta fields from your model instead (e.g. browser_title) | |
# by swapping @page for @casestudy in the line below: | |
present(@page) | |
end | |
def show | |
@casestudy = Casestudy.friendly.find(params[:id]) | |
# you can use meta fields from your model instead (e.g. browser_title) | |
# by swapping @page for @casestudy in the line below: | |
# Takes the view template from the select box in the admin view | |
# and sets the view to that if there is one. | |
viewToRender = @casestudy.template_view.to_s | |
if(viewToRender != ("").to_s) | |
render action: viewToRender.downcase | |
end | |
present(@page) | |
end | |
protected | |
def find_all_casestudies | |
@casestudies = Casestudy.order('position ASC') | |
end | |
def find_page | |
@page = ::Refinery::Page.where(:link_url => "/casestudies").first | |
end | |
# Selects Fluid vs Non-Fluid Layout based on CS Design | |
def selectLayout | |
# Currently the only case is the nTelos CS | |
if(params[:id].to_s == "ntelos-wireless" || params[:id].to_s == "ntelos") | |
"fluid" | |
else | |
"application" | |
end | |
end | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Refinery | |
module Casestudies | |
class Casestudy < Refinery::Core::BaseModel | |
extend FriendlyId | |
friendly_id :title, :use => [:slugged] | |
self.table_name = 'refinery_casestudies' | |
validates :title, :presence => true, :uniqueness => true | |
belongs_to :ctaimage, :class_name => '::Refinery::Image', :foreign_key => :ctaimage_id | |
belongs_to :ctahalfimage, :class_name => '::Refinery::Image', :foreign_key => :cta_half_image_id | |
belongs_to :ourworkimage, :class_name => '::Refinery::Image', :foreign_key => :ourwork_image_id | |
belongs_to :worklistimage, :class_name => '::Refinery::Image', :foreign_key => :worklist_image_id | |
belongs_to :excerpt, :class_name => '::Refinery::Resource' | |
belongs_to :fullcasestudy, :class_name => '::Refinery::Resource' | |
# To enable admin searching, add acts_as_indexed on searchable fields, for example: | |
# | |
# acts_as_indexed :fields => [:title] | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% if @casestudy.css.present? && @casestudy.css.length > 0 %> | |
<% @output_styles = capture do %> | |
<style type="text/css"> | |
<%= raw @casestudy.css %> | |
</style> | |
<% end %> | |
<% end %> | |
<% content_for :body do %> | |
<%=raw @casestudy.body %> | |
<% end %> | |
<%= render '/refinery/content_page', :hide_sections => [:body_content_title] %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment