Module: Workarea::Storefront::DisplayContent
- Included in:
- CategoryViewModel, CheckoutContent, ContentViewModel, EmailSignupsViewModel, InquiryViewModel, MenuViewModel, PageViewModel, SearchContent, SearchCustomizationViewModel
- Defined in:
- app/view_models/workarea/storefront/display_content.rb
Instance Method Summary collapse
- #browser_title ⇒ Object
- #content ⇒ Object
- #content_blocks ⇒ Object
- #content_blocks_for(area) ⇒ Object
- #meta_description ⇒ Object
- #open_graph_asset ⇒ Object
Instance Method Details
#browser_title ⇒ Object
7 8 9 10 11 12 13 |
# File 'app/view_models/workarea/storefront/display_content.rb', line 7 def browser_title if content && content.browser_title.present? content.browser_title elsif model.respond_to?(:name) name end end |
#content ⇒ Object
37 38 39 |
# File 'app/view_models/workarea/storefront/display_content.rb', line 37 def content @content ||= Content.for(content_lookup) end |
#content_blocks ⇒ Object
41 42 43 |
# File 'app/view_models/workarea/storefront/display_content.rb', line 41 def content_blocks content_blocks_for(:default) end |
#content_blocks_for(area) ⇒ Object
45 46 47 48 49 |
# File 'app/view_models/workarea/storefront/display_content.rb', line 45 def content_blocks_for(area) return [] unless content.present? blocks = content.blocks_for(area).select(&:active?) ContentBlockViewModel.wrap(blocks, ) end |
#meta_description ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'app/view_models/workarea/storefront/display_content.rb', line 15 def return content. unless content..blank? t( 'workarea.storefront.layouts.default_meta_description', site_name: Workarea.config.site_name ) end |
#open_graph_asset ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/view_models/workarea/storefront/display_content.rb', line 24 def open_graph_asset @open_graph_asset ||= if content.open_graph_asset_id.present? Content::Asset.find(content.open_graph_asset_id) elsif (og_default = Content::Asset.open_graph_default).present? og_default else Content::Asset.open_graph_placeholder end rescue Mongoid::Errors::DocumentNotFound @open_graph_asset = Content::Asset.open_graph_placeholder end |