Actually, unless you need to override whether the page is even visible, I would override the process_page method instead. But that's just my preference.

In your tags, read the current_front_user off of tag.globals.page. Radius blocks get passed around and the scope can be wonky sometimes.


Sean

Vincent Pérès wrote:
Christopher Dwan wrote:
Vincent,

You have to get SiteController to pass the info into your model,
that's the only way to get the data into a tag AFAIK. So you have to
write an extension for SiteController that adds the function of
passing the current_user's info into your model (e.g. pass in the
user_id). Then you have to either add the ability to receive the
current_user info into Page or into another type of Page like a
UserAuthPage...

Basically I mean something like this... (this code is just for
illustrative purposes and not necessarily the best way to accomplish
this... )

http://pastie.org/261093

-C

Hello,

Thanks for your answer, I'm understanding what you meant.

I created the follwing site controller extension (which is include in my core extension) :

module CoreExtension::SiteControllerExtensions
  def self.included(base)
    base.class_eval do
# This reenables the session for the SiteController - session :on does not work!
      session :disabled => false
      alias_method_chain :find_page, :current_front_user
    end
  end

  def find_page_with_current_front_user(url)
    found = find_page_without_current_front_user(url)
    unless found.nil?
       found.current_front_user = current_user
    end
    found
  end
end


Then, I added the following line in my app/models/page.rb

attr_accessor :current_front_user


And finally, this is my extensions tags file :

module MembersTags
  include Radiant::Taggable

  tag "current_front_user", :for => current_front_user

  tag "if_current_front_user" do |tag|
    if current_front_user
      tag.expand
    end
  end

  tag "unless_current_front_user" do |tag|
    unless current_front_user
      tag.expand
    end
  end
end


When I try to run the server, I got the following error :
"undefined local variable or method current_front_user for MembersTags"

I think it's a basic ruby error, can you give me the way to access to my attribute?

Thank you !
Vincent



_______________________________________________
Radiant mailing list
Post:   Radiant@radiantcms.org
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant

Reply via email to