Can someone explain render_region to me.

5 views
Skip to first unread message

crankin

unread,
Nov 2, 2009, 7:28:47 PM11/2/09
to Radiant CMS: Dev
I love radiant, but trying to find up to date and accurate
documentation is a not easy. I'm trying to figure out how to use the
render_region helper. I see it in views, and in some extensions, but
if I ever try to include it in any of my extensions I'll get an error
like:

You have a nil object when you didn't expect it!
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluating nil.[]

For example

mypage.html.haml

= render_region :top

%p
This will crash


mypage2.html.haml

%p
This works just fine.


What are regions, where are they, what is the benefit of using
render_region? I see it used for tables, etc. What is the point? And
how come it breaks on me? And not other extensions? Should I require
or include something?

Sean Cribbs

unread,
Nov 2, 2009, 8:22:59 PM11/2/09
to radiant...@googlegroups.com
render_region is not really intended to be a public API. What it does
is allow extensions to add view partials to existing spots inside the
stock admin UI, and thus customizing them. For example, if I wanted to
add a partial to the top of the Pages listing/sitemap, I would put this
line in my extension:

admin.pages.index.add :top, "my_partial"

Then the 'render_region :top' call inside
app/views/admin/pages/index.html.haml would render my partial at that
spot. What is key to note here is that Radiant internally populates the
'admin' object with the appropriate data structures to expose the above
API. If you want to provide an extensible view to other extensions, you
might find the 'dashboard' or 'help' extensions illustrative in their
implementations of this API.

Sean

Chris Rankin

unread,
Nov 2, 2009, 8:41:36 PM11/2/09
to radiant...@googlegroups.com
Ok that makes alot of sense.

Thanks,

Chris
Reply all
Reply to author
Forward
0 new messages