Do cells embedded within article content work?

2 views
Skip to first unread message

AndyG

unread,
Nov 19, 2010, 12:21:57 PM11/19/10
to adva-cms
Hi

I've followed the various descriptions of how cells are suposed to
work when embedded within CMS article content, but i can't get it to
actually result in a rendered cell. All i have ever seen so far is the
XML that i put in the CMS content is rendered to screen as raw xml.
How do i instruct the parser to convert that to the output of a cell?

Here's what i put in my article body:

<cell name="blog/recent_articles" count="5" />

All that happens when i save this is this exact XML is then visible in
the HTML source of the viewed article. The XML is not being parsed.

Please advise.

Thanksm

Andy

AndyG

unread,
Nov 19, 2010, 1:16:09 PM11/19/10
to adva-cms
fyi, here are the versions of things on my mac:

ruby: 1.8.7
rails: 2.3.8
adva: 0.3.2

geoffd123

unread,
Nov 20, 2010, 5:10:52 AM11/20/10
to adva-cms
Hi Andy

If you take a look in /vendor/adva/plugins/adva_cells/vendor/plugins/
cells/lib/action_view_extensions.rb

It describes how to render a cell.

Basically your call should be something like:

<%= render_cell :recent_articles :count="5" %>

Cheers
Geoff

AndyG

unread,
Nov 20, 2010, 4:10:12 PM11/20/10
to adva-cms
Geoff

Thanks for your reply. However, this is not the correct syntax (nor in
fact the correct language) to use for when using cells in adva cms
objects (content stored in the database on an adva article). What
you've described here is how to use cells in an erb template, but
that's not where most of the content within an adva site lives; it
lives in the database (well at least that's where most of the content
on the site i'm building will live). An adva cms object (actually a
Globalize::Translation::Attribute) is not equivalent to erb and as
such, you can't put ruby code in their at all (or so i've found out by
trying it). If you do, you'll find that the ruby code is simply
printed directly to screen.

The way the adva team enabled use of cells in adva cms content is via
the use of XML declarations within the html body of the cms object
(such as <cell name="blog/recent_articles" count="5" /> that i pasted
above). This xml is supposed to be parsed and this is suposed to
result in the cell being rendered, but this is not happening for me at
the moment; the xml is instead being rendered into the html page. For
full details of this xml syntax (there's not much in the way of
documentation on the subject), checkout http://groups.google.com/group/adva-cms/web/guide
section 6.11.

Rs

Andy

AndyG

unread,
Nov 20, 2010, 4:13:38 PM11/20/10
to adva-cms
By the way, there's a very reasonable chance that i've got the whole
thing horribly wrong or my dev machine setup incorrectly. That tends
to be the case in these situations ;) Let's hope not in this
situation.

A

On Nov 20, 9:10 pm, AndyG <agoun...@gmail.com> wrote:
> Geoff
>
> Thanks for your reply. However, this is not the correct syntax (nor in
> fact the correct language) to use for when using cells in adva cms
> objects (content stored in the database on an adva article). What
> you've described here is how to use cells in an erb template, but
> that's not where most of the content within an adva site lives; it
> lives in the database (well at least that's where most of the content
> on the site i'm building will live). An adva cms object (actually a
> Globalize::Translation::Attribute) is not equivalent to erb and as
> such, you can't put ruby code in their at all (or so i've found out by
> trying it). If you do, you'll find that the ruby code is simply
> printed directly to screen.
>
> The way the adva team enabled use of cells in adva cms content is via
> the use of XML declarations within the html body of the cms object
> (such as <cell name="blog/recent_articles" count="5" /> that i pasted
> above). This xml is supposed to be parsed and this is suposed to
> result in the cell being rendered, but this is not happening for me at
> the moment; the xml is instead being rendered into the html page. For
> full details of this xml syntax (there's not much in the way of
> documentation on the subject), checkouthttp://groups.google.com/group/adva-cms/web/guide

AndyG

unread,
Nov 20, 2010, 5:40:52 PM11/20/10
to adva-cms
Just had a peak in vendor/adva/plugins/adva_cells/lib/output_filter/
cells.rb

Just starting reading this, but it does look like the filter that
converts the XML cell tag to a cell include.

A

AndyG

unread,
Nov 20, 2010, 6:49:29 PM11/20/10
to adva-cms
Debugging this and i'm certain now that
OutputFilter::Cells::SimpleParser is available to the app, but i'm not
yet clear why it's not being used. SimpleParser.cells method is not
being called. My digging will continue tomorrow.

A

AndyG

unread,
Nov 20, 2010, 7:53:45 PM11/20/10
to adva-cms
OK, it's late and i've not had much time to look at this to make sure
i've done this correctly, but i have been able to get it working. That
said, to achieve this, i've had to modify articles_controller to
forcibly parse the cells XML within the HTML content, based on the
logic in cells.rb

This is what my articles_controller looks like now:

Comments welcome. I'll see how well this works in anger and post any
further feedback.


ActionController::Dispatcher.to_prepare do
ArticlesController.class_eval do
def show
respond_to do |format|
cells =
OutputFilter::Cells.new.parser.cells(@article.body_html)
@article.body_html.gsub!(/(#{cells.keys.join('|')})/) do |tag|
self.response.template.render_cell(*cells[tag])
end unless cells.empty?
format.html { render :template => "#{@section.type.tableize}/
articles/show" }
end
end
end
end

AndyG

unread,
Nov 20, 2010, 7:59:45 PM11/20/10
to adva-cms
Tested a little and it woks fine. Now to work out why it's not being
filtered automatically when article renders...

On Nov 21, 12:53 am, AndyG <agoun...@gmail.com> wrote:
> OK, it's late and i've not had much time to look at this to make sure
> i've done this correctly, but i have been able to get it working. That
> said, to achieve this, i've had to modify articles_controller to
> forcibly parse the cells XML within the HTML content, based on the
> logic in cells.rb
>
> This is what my articles_controller looks like now:
>
> Comments welcome. I'll see how well this works in anger and post any
> further feedback.
>
> ActionController::Dispatcher.to_prepare do
>   ArticlesController.class_eval do
>     def show
>       respond_to do |format|
>         cells =
> OutputFilter::Cells.new.parser.cells(@article.body_html)
>         @article.body_html.gsub!(/(#{cells.keys.join('|')})/) do |tag|
>           self.response.template.render_cell(*cells[tag])
>         end unless cells.empty?
>         format.html { render :template => "#...@section.type.tableize}/
Reply all
Reply to author
Forward
0 new messages