# How create own TAG with dynamic content

**URL:** <https://www.ruby-forum.com/t/how-create-own-tag-with-dynamic-content/121684>\
**Category:** Radiant CMS\
**Created:** [November 29, 2007, 10:46pm UTC](https://www.ruby-forum.com/t/how-create-own-tag-with-dynamic-content/121684 "2007-11-29T22:46:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![michaeln](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b19c9b/32.png) [@michaeln](https://www.ruby-forum.com/u/michaeln)\
**Post date:** [November 29, 2007, 10:46pm UTC](https://www.ruby-forum.com/t/how-create-own-tag-with-dynamic-content/121684/1 "2007-11-29T22:46:19Z")

</div>

Hello. I want create tag wich exec some method of controller and use its  
variables like views in rails. With templates and

example:

controllers/store\_controller.rb:  
class StoreController \< sitecontroller  
def find\_cart  
session[:cart] ||= Cart.new  
end

def add\_to\_cart  
@cart = find\_cart  
@cart.add\_product Product.find( params[:id] )  
end

def initialize  
@cart = find\_cart  
end  
end

modules/cart\_tags.rb:

tag ‘cart:show’ do |tag|  
t = StoreController.new  
@cart = t.cart  
ret = “”  
for cart\_item in @cart  
ret += cart.product+"  
"  
end  
ret  
end

---

<div class="post-metadata">

**Author:** ![michaeln](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b19c9b/32.png) [@michaeln](https://www.ruby-forum.com/u/michaeln)\
**Post date:** [November 30, 2007, 12:45pm UTC](https://www.ruby-forum.com/t/how-create-own-tag-with-dynamic-content/121684/2 "2007-11-30T12:45:02Z")

</div>

You can not do that directly with standard Radiant, you need a Radiant  
\<-\> Rails integration extension.

Search this list for radiant+rails+integration, there have been a few  
post about this topic lately.

/AITOR

---

<div class="post-metadata">

**Author:** ![michaeln](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b19c9b/32.png) [@michaeln](https://www.ruby-forum.com/u/michaeln)\
**Post date:** [November 30, 2007, 1:00pm UTC](https://www.ruby-forum.com/t/how-create-own-tag-with-dynamic-content/121684/3 "2007-11-30T13:00:52Z")

</div>

Aitor Garay-Romero wrote:

> You can not do that directly with standard Radiant, you need a Radiant  
> \<-\> Rails integration extension.
> 
> Search this list for radiant+rails+integration, there have been a few  
> post about this topic lately.
> 
> /AITOR

I for a long time use extension ‘rails\_support’. But I cannot use  
patterns created by radiant cms.  
For example it is necessary to add in tag the list from a method which  
it is stored in the controller.

---

<div class="post-metadata">

**Author:** ![michaeln](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b19c9b/32.png) [@michaeln](https://www.ruby-forum.com/u/michaeln)\
**Post date:** [November 30, 2007, 1:06pm UTC](https://www.ruby-forum.com/t/how-create-own-tag-with-dynamic-content/121684/4 "2007-11-30T13:06:42Z")

</div>

And I want to add. How use AJAX with radiant. I read some source of  
other peole, but they do this very hard.
