Module: ComfyPress::ViewMethods
- Defined in:
- lib/comfypress/view_methods.rb
Instance Method Summary collapse
-
#cms_hook(name, options = {}) ⇒ Object
Injects some content somewhere inside cms admin area.
-
#cms_page_content(identifier, page = nil) ⇒ Object
Content of a page block.
-
#cms_snippet_content(identifier, cms_site = nil) ⇒ Object
Content of a snippet.
-
#comfy_form_for(record, options = {}, &proc) ⇒ Object
Wrapper around ComfyPress::FormBuilder.
Instance Method Details
#cms_hook(name, options = {}) ⇒ Object
Injects some content somewhere inside cms admin area
11 12 13 |
# File 'lib/comfypress/view_methods.rb', line 11 def cms_hook(name, = {}) ComfyPress::ViewHooks.render(name, self, ) end |
#cms_page_content(identifier, page = nil) ⇒ Object
Content of a page block. This is how you get content from page:field Example:
cms_page_content(:left_column, CmsPage.first)
cms_page_content(:left_column) # if @cms_page is present
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/comfypress/view_methods.rb', line 36 def cms_page_content(identifier, page = nil) return '' unless page ||= @cms_page return '' unless block = page.blocks.find_by_identifier(identifier) # If block is a page_file(s) we will return objects instead of attempting # to render them out case block.tag when ComfyPress::Tag::PageFile block.files.first when ComfyPress::Tag::PageFiles block.files else render :inline => ComfyPress::Tag.process_content(page, block.content) end end |
#cms_snippet_content(identifier, cms_site = nil) ⇒ Object
Content of a snippet. Example:
cms_snippet_content(:my_snippet)
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/comfypress/view_methods.rb', line 17 def cms_snippet_content(identifier, cms_site = nil) unless cms_site host, path = request.host.downcase, request.fullpath if respond_to?(:request) && request cms_site ||= (@cms_site || Cms::Site.find_site(host, path)) end return '' unless cms_site case identifier when Cms::Snippet snippet = identifier else return '' unless snippet = cms_site.snippets.find_by_identifier(identifier) end render :inline => ComfyPress::Tag.process_content(cms_site.pages.build, snippet.content) end |
#comfy_form_for(record, options = {}, &proc) ⇒ Object
Wrapper around ComfyPress::FormBuilder
4 5 6 7 8 |
# File 'lib/comfypress/view_methods.rb', line 4 def comfy_form_for(record, = {}, &proc) [:builder] = ComfyPress::FormBuilder [:type] ||= :horizontal formatted_form_for(record, , &proc) end |