Forum: Radiant CMS Accessing application helper from a tag

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.
Dana Janssen (Guest)
on 2007-07-28 01:07
(Received via mailing list)
I've been subscribed to this mailing list for many months now but
this is my first time posting. Please forgive me if I do something
wrong :)

I am trying to use tags to show content based on user session &
permissions. For example, a custom sidebar for when someone is not
logged in, for when they are logged in as an administrator, etc.

In the radiant admin this is performed by erb in /vendor/radiant/app/
views/layouts/application.rhtml. I could create a layout like this,
but then I don't have pages that are editable through radiant.

I believe the problem is that the tag I have written does not see the
radiant application helper. Is there any way to get around this? My
code is below with the error.


from vendor/extensions/session_tags/app/models/session_tags.rb:

module SessionTags
include Radiant::Taggable

desc %{ Check for admin session. }
tag 'session' do |tag|
if admin?
tag.expand
end
end

end


from vendor/radiant/app/helpers/application_helper.rb:

def admin?
user = session['user']
user and user.admin?
end


in the page part:

<r:session>
Put your radius tags here
</r:session>


outputs:

undefined method `admin?' for #
James Thompson (Guest)
on 2007-07-28 01:13
(Received via mailing list)
Can you do a view source and see what the actual object type is that
is indicated by the # in the error. Since objects are returned as
#<ObjectName:124342> they get partially mistaken for HTML tags by
browsers rendering the page.


-James
This topic is locked and can not be replied to.