# How to get access to variables in partials?

**URL:** <https://www.ruby-forum.com/t/how-to-get-access-to-variables-in-partials/118200>\
**Category:** Radiant CMS\
**Created:** [October 24, 2007, 7:17pm UTC](https://www.ruby-forum.com/t/how-to-get-access-to-variables-in-partials/118200 "2007-10-24T19:17:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hans-Christian\_Fjel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/f19dbf/32.png) [@Hans-Christian\_Fjel](https://www.ruby-forum.com/u/Hans-Christian_Fjel)\
**Post date:** [October 24, 2007, 7:17pm UTC](https://www.ruby-forum.com/t/how-to-get-access-to-variables-in-partials/118200/1 "2007-10-24T19:17:08Z")

</div>

This is probably a stupid question, but please bear with me!

I am currently removing the admin\_parts dependency from the comments  
extension, and replacing this with shards instead, as I feel this  
will make all happy, and will be better supported in the future.

I am also trying to add some extra stuff, and this is where I get  
into trouble.

I am trying to extend the node\_row region with a link to the comments  
for the current page. In CommentsExtension I have:

admin.page.index.add :node\_row, “index\_view\_comments”

This works great, but the problem is getting the current page into  
the index\_view\_comments partial.

The solution is probably easy, and since I have already tried to  
long, I though I just ask for some expert help here 🙂

Greetings

Hans-Christian Fjeldberg  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![Hans-Christian\_Fjel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/f19dbf/32.png) [@Hans-Christian\_Fjel](https://www.ruby-forum.com/u/Hans-Christian_Fjel)\
**Post date:** [October 24, 2007, 7:30pm UTC](https://www.ruby-forum.com/t/how-to-get-access-to-variables-in-partials/118200/2 "2007-10-24T19:30:28Z")

</div>

Hans,

I needed that functionality myself and thought it would be especially  
appropriate for the sitemap rows, so I added it this morning.  
Essentially the options passed to render\_region are passed on to the  
individual partials. In this case, :locals =\> {:page =\> page, :level =\>  
level} is passed. Then you have those variables accessible within your  
partial.

I have some ideas about how to better modularize the sitemap, including  
a core patch to cleanup \_node.rhtml, but I’d entertain some suggestions  
– especially ones derived from real usage scenarios.

Sean

---

<div class="post-metadata">

**Author:** ![Hans-Christian\_Fjel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/f19dbf/32.png) [@Hans-Christian\_Fjel](https://www.ruby-forum.com/u/Hans-Christian_Fjel)\
**Post date:** [October 24, 2007, 11:14pm UTC](https://www.ruby-forum.com/t/how-to-get-access-to-variables-in-partials/118200/3 "2007-10-24T23:14:41Z")

</div>

That worked, thank you.

I’ll try to release my patches for the comments extension tomorrow  
Norwegian time…

As I do not know exactly how the site-map works, I don’t have any  
great ideas, but I do agree \_node.rhtml has a lot of code that should  
rather be in a helper or something.

Greetings

Hans-Christian Fjeldberg  
removed\_email\_address@domain.invalid
