Sha256: b813b349d3d49fbf25784f1ef0765de23c820e7324c470841d585c5652b17b44

Contents?: true

Size: 955 Bytes

Versions: 14

Compression:

Stored size: 955 Bytes

Contents

# frozen_string_literal: true

module Decidim
  # A Helper to render the Call To Action button.
  module CtaButtonHelper
    # Renders the Call To Action button. Link and text can be configured
    # per organization.
    def cta_button
      button_text = translated_attribute(current_organization.cta_button_text).presence || t("pages.home.hero.participate")

      link_to button_text, cta_button_path, class: "hero-cta button expanded large button--sc"
    end

    # Finds the CTA button path to reuse it in other places.
    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.account_path
      else
        decidim.new_user_registration_path
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
decidim-core-0.11.2 app/helpers/decidim/cta_button_helper.rb
decidim-core-0.11.1 app/helpers/decidim/cta_button_helper.rb
decidim-core-0.11.0.pre1 app/helpers/decidim/cta_button_helper.rb
decidim-core-0.10.1 app/helpers/decidim/cta_button_helper.rb
decidim-core-0.10.0 app/helpers/decidim/cta_button_helper.rb
decidim-core-0.9.3 app/helpers/decidim/cta_button_helper.rb
decidim-core-0.9.2 app/helpers/decidim/cta_button_helper.rb
decidim-core-0.9.1 app/helpers/decidim/cta_button_helper.rb
decidim-core-0.9.0 app/helpers/decidim/cta_button_helper.rb
decidim-core-0.8.4 app/helpers/decidim/cta_button_helper.rb
decidim-core-0.8.3 app/helpers/decidim/cta_button_helper.rb
decidim-core-0.8.2 app/helpers/decidim/cta_button_helper.rb
decidim-core-0.8.1 app/helpers/decidim/cta_button_helper.rb
decidim-core-0.8.0 app/helpers/decidim/cta_button_helper.rb