Tags, ActionView::Helpers, caching: trying to make a shop ex


#1

Hello everybody,

Using the ‘mental’ branche:

I’m trying to make a shop extension with the help of the well know book
‘agile web development…’ and of course after alot of reading at the
lists and the radiant site.

I’ve succesfully used tags to have make a nice <product:each /> block
and
now I want to have a <product:addtocartbutton /> for I’d love to use the
nice ActionView::Helpers which you appearantly all loose and need to
include yourself. Why is this? I love rails alot for this. Wouldn’t this
help people alot?
I’ve tried including them but UrlHelper needs an ‘url_for’ attribute
which
I have not succeeded to supply. Has anyone else succeeded? I stoppped
here
because it doesn’t seem the right way to go I guess.

So…I think I need at least one controller available in the site, in
which I succeeded using

map.connect ‘shop/:action’, :controller => ‘shop’

now it’s clear how to disable the need for authentication but now I need
to get rid of the application.rhtml markup. If I define my own, it
completly overwrites the original which is not what I ment of course.
Second, every site user needs a shopping cart, so I’ve uncommented
‘sessions: off’. I’ve read something about caching session headers but I
tested and looking at the cookies _session_id behaved normal as far as I
could see. This is not an issue anymore?

To sumarize my questions:

What would be the best way to continue to use the ActionView::Helpers
for
parts in you’re site?

How do I get rid of the standard backend application.rhtml without
completly overwriting it if this will be the way to go?

Now I also need to supply the snippet of the shopping cart in the
template
on every page. Does this mean I need to disable caching for the whole
site? Is there a way I could inject a small piece of evaluated code on
every page?

Thank’s alot for any hint in the right direction.

kozy


#2

Yes, this is a weakness of Radius.

I guess you could try to use include to put the ActionView helper
modules into your tag module, but you may have to read a lot of the
Rails internals code to figure out how to make them work properly. In
an extension I’m working on, I started including them but then
determined it was just too much work except for the most trivial of
uses. I would just decide on a URL path for your controller and generate
the URL from that.

Regarding the layout issue, instead of overriding application.rhtml, put
layout 'shop' in your controller and then define shop.rhtml.

If the user browses to your controller and the session isn’t turned off,
a session will begin for them. The nice thing about the extensions
pattern is that Radiant doesn’t care if the /shop URL goes to your own
controller rather than a Radiant page. So basically you can choose to
integrate however much or little you want with Radiant’s functionality.

Sean