Created
May 9, 2013 22:57
-
-
Save levibrown/5551233 to your computer and use it in GitHub Desktop.
content methods
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def pay_online(name, link, css_class) | |
if @store && @store.remote_store_url | |
link_to("#{name}<span></span>".html_safe, @store.remote_store_url, :class => "#{css_class} pay_online", :target => '_blank') | |
elsif @client.stores.first.pay_online_corp | |
link_to("#{name}<span></span>".html_safe, content_url(:page => 'pay_online', :host => determine_host_name), :class => "#{css_class} pay_online", :target => '_blank') | |
else | |
end | |
end | |
def lead_link(name, link, css_class) | |
object_type = @store ? "store" : "client" | |
object = @store ? @store : @client | |
link_to("#{name}".html_safe, | |
leads_url(:lead_type => "#{link}", | |
:lead_reference_type => object_type, | |
:lead_reference_id => object.id), :class => "#{css_class}") | |
end | |
def config_link_out(type, name, link, css_class="") | |
case type | |
when "location_page" | |
link_to("#{name}".html_safe, @store.page_url("#{link}"), :class => "#{css_class}") if @store | |
when "corp_page" | |
link_to("#{name}".html_safe, content_url(:page => "#{link}", :host => determine_host_name), :class => "#{css_class}") | |
when "external" | |
link_to("#{name}".html_safe, link, :class => "#{css_class}", :target => '_blank') | |
when "pay_online" | |
pay_online(name, link, css_class) | |
when "lead" | |
lead_link(name, link, css_class) | |
when "coupon" | |
object = @store ? @store : @client | |
link_to("#{name}".html_safe, url_for(:action => 'coupon', :id => object), :class => "#{css_class}") | |
end | |
end | |
def cta_link(cv_name, css_class="") | |
object = @store ? @store : @client.stores.first | |
setup = object.send(cv_name.to_sym).split(",") | |
config_link_out(setup[0], setup[1], setup[2], css_class="#{css_class}") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment