# E Commerce as Behavior?

**URL:** <https://www.ruby-forum.com/t/e-commerce-as-behavior/82000>\
**Category:** Radiant CMS\
**Created:** [January 16, 2007, 8:18pm UTC](https://www.ruby-forum.com/t/e-commerce-as-behavior/82000 "2007-01-16T20:18:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mattmcswain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ecb155/32.png) [@mattmcswain](https://www.ruby-forum.com/u/mattmcswain)\
**Post date:** [January 16, 2007, 8:18pm UTC](https://www.ruby-forum.com/t/e-commerce-as-behavior/82000/1 "2007-01-16T20:18:21Z")

</div>

Hi,

I posted this earlier but think there may have been a problem. So I hope  
this didn’t get posted twice!

I’m considering using Radiant for a site, but the site needs a basic  
e-commerce package also. Does it seem feasible to integrate e commerce  
functionality by using behaviors? If not, how would one go about adding  
this  
kind of functionality on top of Radiant?

Thanks!

- matt

---

<div class="post-metadata">

**Author:** ![mattmcswain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ecb155/32.png) [@mattmcswain](https://www.ruby-forum.com/u/mattmcswain)\
**Post date:** [January 16, 2007, 8:24pm UTC](https://www.ruby-forum.com/t/e-commerce-as-behavior/82000/2 "2007-01-16T20:24:22Z")

</div>

Quoting “Matt M.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> Thanks!
> 
> - matt

Matt,

Shouldn’t be a problem, but can’t recommend going with behaviors. Short  
answer:  
Radiant “mental” branch and extensions (instead of behaviors). Besides  
checking  
out mental, you can gain a bunch of insight into extensions by searching  
the  
mailing list or check the Sean’s post on the Weblog link on the Radiant  
site.  
I believe documentation is on the way.

Hope this helps,  
Todd

---

<div class="post-metadata">

**Author:** ![mattmcswain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ecb155/32.png) [@mattmcswain](https://www.ruby-forum.com/u/mattmcswain)\
**Post date:** [January 16, 2007, 10:58pm UTC](https://www.ruby-forum.com/t/e-commerce-as-behavior/82000/3 "2007-01-16T22:58:55Z")

</div>

I’m doing something similar whereby I have a Radiant powered site,  
with commerce functionality. My approach was to write an  
ExternalContent behavior which allows me to do the following in Radiant:

\<r:external\_content url=“[http://another-rails-app.com/products/list](http://another-rails-app.com/products/list)” /\>

The above will then pull in a partial page from another Rails app  
which implements the commerce functionality.

The way I look at it, Radiant is great for content management. But  
extending Radiant from within to do anything other than content  
management seems inelegant to me. Instead, coding your Rails app  
externally allows you to do anything, and at the same time, provide  
content to Radiant.

Cheers, Joannou.

He who knows best knows how little he knows. - Thomas Jefferson

---

<div class="post-metadata">

**Author:** ![mattmcswain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ecb155/32.png) [@mattmcswain](https://www.ruby-forum.com/u/mattmcswain)\
**Post date:** [January 19, 2007, 4:31pm UTC](https://www.ruby-forum.com/t/e-commerce-as-behavior/82000/4 "2007-01-19T16:31:34Z")

</div>

Very straightforward.

Create a new file, external\_content\_behavior.rb, in app/behaviors,  
with the following content:

class ExternalContentBehavior \< Behavior::Base  
register ‘External Content’  
description ‘Get and render external content.’

define\_tags do  
tag ‘external\_content’ do |tag|  
require ‘open-uri’

```
   open(tag.attr['url']).read
 end

```

end  
end

Cheers, Joannou.

Hope is not a strategy. - Michael Henos

---

<div class="post-metadata">

**Author:** ![mattmcswain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ecb155/32.png) [@mattmcswain](https://www.ruby-forum.com/u/mattmcswain)\
**Post date:** [January 16, 2007, 11:25pm UTC](https://www.ruby-forum.com/t/e-commerce-as-behavior/82000/5 "2007-01-16T23:25:04Z")

</div>

Joannou Ng wrote:

> I’m doing something similar whereby I have a Radiant powered site, with  
> commerce functionality. My approach was to write an ExternalContent  
> behavior which allows me to do the following in Radiant:
> 
> \<r:external\_content url=“[http://another-rails-app.com/products/list](http://another-rails-app.com/products/list)” /\>

Hello Joannou. It seems to me a practical and effective approach.  
Wouldn’t you mind to share the code of the tag? Many thanks in advance.  
L
