Forum: Radiant CMS Radiant: Page attachments each

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Mailing (Guest)
on 2007-07-29 14:19
(Received via mailing list)
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
Sean C. (Guest)
on 2007-07-29 21:46
(Received via mailing list)
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>
<p><r:link /> - <r:date /></p>
</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!
Mailing (Guest)
on 2007-07-29 21:54
(Received via mailing list)
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*
Sean C. (Guest)
on 2007-07-29 21:56
(Received via mailing list)
Yes, that's the bug I just fixed.  Please run `svn up` or export the
extension again.

Sean
Mailing (Guest)
on 2007-07-29 22:22
(Received via mailing list)
Just tried that but I get the same error? Any ideas?
Sean C. (Guest)
on 2007-07-30 15:42
(Received via mailing list)
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
Mailing (Guest)
on 2007-07-30 15:53
(Received via mailing list)
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">
<p><r:link /> - <r:date /></p>
</r:attachment:each>

Any ideas?

Keith
This topic is locked and can not be replied to.