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

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



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

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

  link_to 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.



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

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