# Page\_attachments

**URL:** <https://www.ruby-forum.com/t/page-attachments/109666>\
**Category:** Radiant CMS\
**Created:** [July 17, 2007, 6:32pm UTC](https://www.ruby-forum.com/t/page-attachments/109666 "2007-07-17T18:32:45Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_Pyschny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/4da419/32.png) [@Michael\_Pyschny](https://www.ruby-forum.com/u/Michael_Pyschny)\
**Post date:** [July 17, 2007, 6:32pm UTC](https://www.ruby-forum.com/t/page-attachments/109666/1 "2007-07-17T18:32:45Z")

</div>

Hi,

some kind of usage problems with page\_attachments:

1. 

has somebody found out how to cycle through page\_attachments?  
I want to render all the attachments as a list or in a gallery like  
format but could not find something like \<r:attachment:each /\>  
\<r:attachment:first /\>  
\<r:attachment:next /\>  
\<r:attachment:previous /\>  
\<r:attachment:count /\>  
\<r:attachment:last /\>

1. 

can the upload attachment functionality be made accessible from within a  
non-admin page (i.e. from the front-end,  
something like Asset-Upload?)

Thanks for your help.  
Cheers,  
Michael

---

<div class="post-metadata">

**Author:** ![Michael\_Pyschny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/4da419/32.png) [@Michael\_Pyschny](https://www.ruby-forum.com/u/Michael_Pyschny)\
**Post date:** [July 17, 2007, 9:10pm UTC](https://www.ruby-forum.com/t/page-attachments/109666/2 "2007-07-17T21:10:20Z")

</div>

Michael,

1. page\_attachments assumes you want a particular file accessible from a  
particular page or its children. It also assumes you know the name of  
the file and makes no assumptions about the format of the file, be it  
text, image or some other binary format. There is no way to iterate  
through the attachments of any given page.
2. This again falls out of the scope of page\_attachments. I wouldn’t  
want random visitors uploading files into my page, so I didn’t add that  
functionality.

Overall, it sounds like you want some full-fledged gallery software.  
The gallery extension might fit your needs. There’s also always room  
for another extension that implements the functionality you desire.

Sean

---

<div class="post-metadata">

**Author:** ![Michael\_Pyschny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/4da419/32.png) [@Michael\_Pyschny](https://www.ruby-forum.com/u/Michael_Pyschny)\
**Post date:** [July 17, 2007, 10:34pm UTC](https://www.ruby-forum.com/t/page-attachments/109666/3 "2007-07-17T22:34:32Z")

</div>

1. imho it’s not very good assumption… iteration would be VERY useful  
feature  
for example to easily create javascript-based gallery. when i create  
page  
Gallery i won’t attach anything except images i want to show…

2. i agree with Sean…

---

<div class="post-metadata">

**Author:** ![Michael\_Pyschny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/4da419/32.png) [@Michael\_Pyschny](https://www.ruby-forum.com/u/Michael_Pyschny)\
**Post date:** [July 17, 2007, 10:55pm UTC](https://www.ruby-forum.com/t/page-attachments/109666/4 "2007-07-17T22:55:35Z")

</div>

On 7/17/07, Sean C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Michael,
> 
> 1. page\_attachments assumes you want a particular file accessible from a  
> particular page or its children. It also assumes you know the name of  
> the file and makes no assumptions about the format of the file, be it  
> text, image or some other binary format. There is no way to iterate  
> through the attachments of any given page.

Mmm, I disagree…

What If want to attach a few files and show them inside a table? Just  
the name and the size, which will allow me later replace those files  
with updated ones without thinking on the name of the file 🙂

> 1. This again falls out of the scope of page\_attachments. I wouldn’t  
> want random visitors uploading files into my page, so I didn’t add that  
> functionality.

But I agree on this… file uploads from front-end is way beyond the  
scope of page\_attachments… also, i see a lot of attempts to convert  
those sites to a pr0n web storage 😛

## – Luis L. Multimedia systems

Leaders are made, they are not born. They are made by hard effort,  
which is the price which all of us must pay to achieve any goal that  
is worthwhile.  
Vince Lombardi

---

<div class="post-metadata">

**Author:** ![Michael\_Pyschny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/4da419/32.png) [@Michael\_Pyschny](https://www.ruby-forum.com/u/Michael_Pyschny)\
**Post date:** [July 18, 2007, 6:56am UTC](https://www.ruby-forum.com/t/page-attachments/109666/5 "2007-07-18T06:56:41Z")

</div>

Adding some iteration tags is actually not very hard. You can easily  
find all page attachments for a given page and cycle through them. I  
have done this, but I am not sure where the tags are… 🙂 I prefer  
some sort of gallery plugin for such things, but sometimes it is nice  
to have a few images together. I will see if I can find the tags and  
post them.

As for the second part, I would have to agree with Sean.

Keith B.  
Tel: +49-7731-7983830  
removed\_email\_address@domain.invalid  
[http://keithbingman.com](http://keithbingman.com)

---

<div class="post-metadata">

**Author:** ![Michael\_Pyschny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/4da419/32.png) [@Michael\_Pyschny](https://www.ruby-forum.com/u/Michael_Pyschny)\
**Post date:** [July 18, 2007, 10:17am UTC](https://www.ruby-forum.com/t/page-attachments/109666/6 "2007-07-18T10:17:58Z")

</div>

Hi

On Tue, 2007-07-17 at 23:33 +0300, Keymone wrote:

> 1. imho it’s not very good assumption… iteration would be VERY useful  
> feature  
> for example to easily create javascript-based gallery. when i create page  
> Gallery i won’t attach anything except images i want to show…

Who’s developing it? 😉

> 1. i agree with Sean…

I use Adreas Subscriber extension and upload will only be allowed for  
logged in members …and the quota can easily be controlled by the  
page\_attachment extension. Quota itself will be defined in the  
subscriber config or on per subscriber base. Sounds like a basic asset  
management…he?

Cheers  
Michael

---

<div class="post-metadata">

**Author:** ![Michael\_Pyschny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/4da419/32.png) [@Michael\_Pyschny](https://www.ruby-forum.com/u/Michael_Pyschny)\
**Post date:** [July 18, 2007, 3:15pm UTC](https://www.ruby-forum.com/t/page-attachments/109666/7 "2007-07-18T15:15:52Z")

</div>

Keith B. wrote:

> Adding some iteration tags is actually not very hard. You can easily  
> find all page attachments for a given page and cycle through them. I  
> have done this, but I am not sure where the tags are… 🙂 I prefer  
> some sort of gallery plugin for such things, but sometimes it is nice  
> to have a few images together. I will see if I can find the tags and  
> post them.

I wasn’t challenging the difficulty, just that I personally don’t need  
it. As always with open-source software, anyone is welcome to modify  
it. I can see some compelling use cases for iteration, but  
page\_attachments was never meant to be a gallery.

Sean

---

<div class="post-metadata">

**Author:** ![Michael\_Pyschny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/4da419/32.png) [@Michael\_Pyschny](https://www.ruby-forum.com/u/Michael_Pyschny)\
**Post date:** [July 19, 2007, 5:57pm UTC](https://www.ruby-forum.com/t/page-attachments/109666/8 "2007-07-19T17:57:10Z")

</div>

To iterate over attachments like this:

\<r:attachments:each\>  
\<r:attachment:url /\>  
\</r:attachments:each\>

Add these tags to page\_attachment\_tags.rb:

desc %{  
Gives access to a page’s attachments.

```
 *Usage:*
 <pre><code><r:attachments>...</r:attachments></code></pre>

```

}  
tag “attachments” do |tag|  
tag.locals.attachments = tag.locals.page.attachments  
tag.expand  
end

desc %{  
Cycles through each of the attachments. Inside this tag all  
attachments  
are mapped to the current attachment.

```
 *Usage:*
 <pre><code><r:attachments:each>
  ...
 </r:attachments:each>
 </code></pre>

```

}  
tag “attachments:each” do |tag|  
result = []  
tag.locals.attachments.each do |attachment|  
tag.locals.attachment = attachment  
result \<\< tag.expand  
end  
result  
end

On Jul 18, 2007, at 3:15 AM, Michael Pyschny wrote:

> > 
> 
> management…he?
> 
> > > from a  
> > > functionality.  
> > > Radiant mailing list  
> > > Post: removed\_email\_address@domain.invalid  
> > > Search: [http://radiantcms.org/mailing-list/search/](http://radiantcms.org/mailing-list/search/)  
> > > Site: [http://lists.radiantcms.org/mailman/listinfo/radiant](http://lists.radiantcms.org/mailman/listinfo/radiant)

* * *

Ryan H.  
Art of Mission, Inc.  
3720 Gattis School Rd #800 PMB 245  
Round Rock, TX 78664

800-722-1492 (phone)

[www.artofmission.com](http://www.artofmission.com)  
removed\_email\_address@domain.invalid
