Last active
August 29, 2015 14:03
-
-
Save anitagraham/64261524f13a3ec89bc5 to your computer and use it in GitHub Desktop.
Integrate plugins
This file contains hidden or 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
# refinerycms-pages/views/admin/pages/_form_page_parts.html.erb | |
..... | |
<div id='page_part_editors'> | |
<% part_index = -1 %> | |
<%= f.fields_for :parts do |p| %> | |
<% template = p.object[:template] || 'page_part_field' %> | |
<%= render template, | |
:part => p.object, | |
:part_index => (part_index += 1), | |
:new_part => @page.new_record? -%> | |
<% end %> | |
<% ::Refinery::Pages.tabs_for_template(@page.view_template).each_with_index do |tab, tab_index| %> | |
<div class='page_part' id='<%= "custom_tab_#{tab_index}" %>'> | |
<%= render tab.partial, :f => f %> | |
</div> | |
<% end %> | |
</div> |
This file contains hidden or 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
# refinerycms-testimonials/app/views/refinery/admin/pages/_position_tab.html.erb | |
<div class='page_part position_only' id='<%= new_part ? "page_part_new_#{part_index}" : part.to_param %>'> | |
<h1><%= t('.title')%></h1> | |
<p> <%= t('.reorder_only')%> | |
</div> | |
This file contains hidden or 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
# refinerycms-testimonials/app/decorators/models/refinery/page_decorator.rb | |
# Open the Refinery::Page model for manipulation | |
Refinery::Page.class_eval do | |
# Whitelist the testimonials control fields | |
attr_accessible :testimonials_show, :testimonials_count, :testimonials_select | |
validates :testimonials_count, :numericality => { :only_integer => true, :greater_than_or_equal_to=>0 } | |
before_save :testimonial_page_part | |
def testimonial_page_part | |
if testimonials_show && !part_with_title('Testimonials') | |
parts.build(title: 'Testimonials', position: parts.count, template: 'position_tab') | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Notes