Module: Decidim::CtaButtonHelper

Included in:
Decidim::ContentBlocks::HeroCell
Defined in:
app/helpers/decidim/cta_button_helper.rb

Overview

A Helper to render the Call To Action button.

Instance Method Summary collapse

Instance Method Details

#cta_buttonObject



12
13
14
# File 'app/helpers/decidim/cta_button_helper.rb', line 12

def cta_button
  link_to cta_button_text, cta_button_path, class: "hero-cta button expanded large button--sc", title: t("decidim.pages.home.hero.participate_title")
end

#cta_button_pathObject

Finds the CTA button path to reuse it in other places.



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/helpers/decidim/cta_button_helper.rb', line 17

def cta_button_path
  if current_organization.cta_button_path.present?
    current_organization.cta_button_path
  elsif Decidim::ParticipatoryProcess.where(organization: current_organization).published.any?
    decidim_participatory_processes.participatory_processes_path
  elsif current_user
    decidim.
  elsif current_organization.
    decidim.new_user_registration_path
  else
    decidim.new_user_session_path
  end
end

#cta_button_textObject

Renders the Call To Action button. Link and text can be configured per organization.



8
9
10
# File 'app/helpers/decidim/cta_button_helper.rb', line 8

def cta_button_text
  translated_attribute(current_organization.cta_button_text).presence || t("decidim.pages.home.hero.participate")
end