# Radiant: Page attachments each

**URL:** <https://www.ruby-forum.com/t/radiant-page-attachments-each/110673>\
**Category:** Radiant CMS\
**Created:** [July 29, 2007, 12:19pm UTC](https://www.ruby-forum.com/t/radiant-page-attachments-each/110673 "2007-07-29T12:19:02Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [July 29, 2007, 12:19pm UTC](https://www.ruby-forum.com/t/radiant-page-attachments-each/110673/1 "2007-07-29T12:19:02Z")

</div>

Hi,

Has anyone managed to use the page attachments extension to display all  
attachments relating to a page by using \<r:attachments:each\>? Seems as  
though it can only be used if you can specify the name at the moment?

Has anyone got any example code for this?

Keith

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [July 29, 2007, 7:46pm UTC](https://www.ruby-forum.com/t/radiant-page-attachments-each/110673/2 "2007-07-29T19:46:52Z")

</div>

Keith,

I quietly added that feature the other day. It is kind of untested.  
However, because of the assignment of tag.locals.attachment inside the  
loop, it should work properly, but only for the current page. It will  
not cascade to parent pages. Here’s a snippet of how it should work:

\<r:attachment:each\>

-

That would conceivably print a link to each attachment in a paragraph  
with its upload date.

Sean

P.S. I just found and fixed a minor bug in the order clause. I hope  
that wasn’t your problem!

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [July 29, 2007, 7:54pm UTC](https://www.ruby-forum.com/t/radiant-page-attachments-each/110673/3 "2007-07-29T19:54:53Z")

</div>

Sean,

Yeah - I started off by trying that - only I get the following Mysql  
error in the area of the page I’d expect to see the links printed.

Any ideas??

_Mysql::Error: You have an error in your SQL syntax; check the manual  
that corresponds to your MySQL server version for the right syntax to  
use near ‘asc id’ at line 1: SELECT \* FROM page\_attachments WHERE  
(page\_attachments.page\_id = 8) ORDER BY asc id_

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [July 29, 2007, 8:22pm UTC](https://www.ruby-forum.com/t/radiant-page-attachments-each/110673/4 "2007-07-29T20:22:58Z")

</div>

Just tried that but I get the same error? Any ideas?

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [July 29, 2007, 7:56pm UTC](https://www.ruby-forum.com/t/radiant-page-attachments-each/110673/5 "2007-07-29T19:56:54Z")

</div>

Yes, that’s the bug I just fixed. Please run `svn up` or export the  
extension again.

Sean

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [July 30, 2007, 1:53pm UTC](https://www.ruby-forum.com/t/radiant-page-attachments-each/110673/6 "2007-07-30T13:53:32Z")

</div>

Thanks Sean,

I’ve fixed that error - I believe - now when I use the following code I  
simply get a # sign in the place of each attachment. I am using the  
following code within a snippet that is used on five child pages within  
a branch of the site (HOME \> PRODUCTS \> _5 PRODUCT PAGES_:

\<r:attachment:each order=“asc”\>

-

Any ideas?

Keith

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [July 30, 2007, 1:42pm UTC](https://www.ruby-forum.com/t/radiant-page-attachments-each/110673/7 "2007-07-30T13:42:31Z")

</div>

If it’s the exact same error, then you didn’t get the latest update.  
Notice that the terms in the ORDER BY clause are transposed; I fixed  
that in that in the latest revision. It should read “id asc”.

Sean
