Forum: Radiant CMS Inheriting behaviors

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
280577cc02ad50d7776afde4d852b22b?d=identicon&s=25 Justin Marney (Guest)
on 2006-06-09 23:45
(Received via mailing list)
Hi all,

I was wondering is it possible to inherit behaviors?  Example: The
mailer
behavior defines some form tags that could be made fairly generic with
minor
tweaking.  It seems like generic form tags would be pretty useful.  I
was
trying to do something like:

module FormBehavior
  def self.append_features(base)
    base.class_eval %{
      define_tags do
        tag "#{form_name}:form" do |tag|
          tag_attr = tag.attr.symbolize_keys
          results =  %Q(<form action="#{page.url}" method="POST"
enctype="multipart/form-data">)
          results << tag.expand
          results << %Q(</form>)
        end
      end
    }
  end
end

But #{form_name} and #{page.url} both get evaluated in the context of
the
module.  There is most likely a simpel way around this but at least that
code shows the gist of what I'm trying to do.

Any ideas, help, thoughts would be appriciated.

Thanks!
Justin
6ec6f77ea603dd75b3a7a7775b059e79?d=identicon&s=25 John W. Long (Guest)
on 2006-06-12 17:46
(Received via mailing list)
Justin Marney wrote:
>    base.class_eval %{
>  end
> end
>
> But #{form_name} and #{page.url} both get evaluated in the context of the
> module.  There is most likely a simpel way around this but at least that
> code shows the gist of what I'm trying to do.
>
> Any ideas, help, thoughts would be appriciated.

Why not do this:

   require 'behaviors/mailer_behavior'

   MailerBehavior.define_tags do
     define_tags do
       tag "#{form_name}:form" do |tag|
         tag_attr = tag.attr.symbolize_keys
         results =  %Q(<form action="#{page.url}" method="POST"
   enctype="multipart/form-data">)
         results << tag.expand
         results << %Q(</form>)
       end
     end
   end

?

--
John Long
http://wiseheartdesign.com
B4163b1648c7f1809f0e727c6e7fefde?d=identicon&s=25 Tristan Boniver (Guest)
on 2006-06-13 10:36
(Received via mailing list)
During a migration to radiant, we had to correct the publish date of
archived posts via the database;  we had a little idea:

'status of a page' select box is now:
-draft
-reviewed
-published
-hidden

wouldn't it be nice to have:
-draft
-reviewed
-publish now
-publish on...
-hidden

It  allows the schedule of a post, and even modifying a publication
date in the past.
This topic is locked and can not be replied to.