module Alchemy module PagesHelper include Alchemy::BaseHelper include Alchemy::ElementsHelper def picture_essence_caption(content) content.try(:essence).try(:caption) end # Renders links to language root pages of all published languages. # # @option options linkname [String] ('name') # Renders name/code of language, or I18n translation for code. # # @option options show_title [Boolean] (true) # Renders title attributes for the links. # # @option options spacer [String] ('') # Renders the passed spacer string. You can also overwrite the spacer partial: "alchemy/language_links/_spacer". # # @option options reverse [Boolean] (false) # Reverses the ordering of the links. # def language_links(options={}) options = { linkname: 'name', show_title: true, spacer: '', reverse: false }.merge(options) languages = Language.published.with_root_page.order("name #{options[:reverse] ? 'DESC' : 'ASC'}") return nil if languages.count < 2 render( partial: "alchemy/language_links/language", collection: languages, spacer_template: "alchemy/language_links/spacer", locals: {languages: languages, options: options} ) end # Renders the layout for current page. # # Page layout files belongs in +/app/views/alchemy/page_layouts/+ # # Falls back to +/app/views/alchemy/page_layouts/standard+ if the page_layout partial is not found. # def render_page_layout render @page, page: @page rescue ActionView::MissingTemplate warning("PageLayout: '#{@page.page_layout}' not found. Rendering standard page_layout.") render 'alchemy/page_layouts/standard', page: @page end # Renders a partial for current site # # Place a rails partial into +app/views/alchemy/site_layouts+ # # and name it like your site name. # # == Example: # # <%= render_site_layout %> # # renders +app/views/alchemy/site_layouts/_default_site.html.erb+ for the site named "Default Site". # def render_site_layout render current_alchemy_site rescue ActionView::MissingTemplate warning("Site layout for #{current_alchemy_site.try(:name)} not found. Please run `rails g alchemy:site_layouts`") return "" end # Renders the navigation. # # It produces a html structure with all necessary classes so you can produce every navigation the web uses today. # I.E. dropdown-navigations, simple mainnavigations or even complex nested ones. # # === HTML output: # # # # As you can see: Everything you need. # # Not pleased with the way Alchemy produces the navigation structure? # # Then feel free to overwrite the partials (_renderer.html.erb and _link.html.erb) found in +views/navigation/+ or pass different partials via the options +:navigation_partial+ and +:navigation_link_partial+. # # === Passing HTML classes and ids to the renderer # # A second hash can be passed as html_options to the navigation renderer partial. # # ==== Example: # # <%= render_navigation({from_page: 'subnavi'}, {class: 'navigation', id: 'subnavigation'}) %> # # # @option options submenu [Boolean] (false) # Do you want a nested