1–n file attachments

Galen King's Avatar

Galen King

25 Feb, 2010 03:00 AM via web

Hi guys,

It would be great if a file field could be set to ask for a single file or an unlimited number.

Am I right in understanding that a page can have just one file per file field? How then, for example, could we set it up so a client could have a number of banner images that then get cross-faded via Javascript?

The way I've set it up is that I've added a file upload field to the Home template so they can choose an image when editing the content. It's accessed in the theme with {{ site.navigation.first.data.banner.url }}.

It would be awesome if we could do something like this:

{% for image in site.navigation.first.data.banners %}

<img src="{{ image.url }}" />

{% endfor %}

Your thoughts?

Cheers,

Galen

  1. 2 Posted by John Nunemaker on 25 Feb, 2010 03:06 AM

    John Nunemaker's Avatar

    We completely agree and totally want it too. It is definitely on the list
    and the Files tab was just a small preview of how it will function.

  2. 3 Posted by Galen King on 25 Feb, 2010 03:20 AM

    Galen King's Avatar

    Cool. Awesome. Thanks.

  3. Support Staff 4 Posted by Steve Smith on 25 Feb, 2010 03:20 AM

    Steve Smith's Avatar

    For now, you could do this one of two ways:

    1. Simply place the max number of banner images as template data (eg. 5 max images, create 5 individual image uploads).

    2. If you truly want a more high-limit number, you could create a template with one image field, and then create a parent 'page' called Banners, unpublished, then create 'subpages' under that for each banner, using the banner template to collect the data. Then, cycle through those children to output your banners.

    Neither of these is ideal at the moment, but will work until a more robust system can be put in place for repeatable template data.

  4. 5 Posted by Galen King on 25 Feb, 2010 03:29 AM

    Galen King's Avatar

    Hi Steve,

    I'm just now trying to figure out how to access a page object that's not published.

    For example, we are currently using the Home template as a kind of "configuration" space where we can specify Google Analytics code, banner image, site subtitle etc.

    We access it like this:

    {{ site.navigation.first.data.… }}

    But this only works if the Home page is shown in the navigation.

    Is there a better way to access a page and its subpages when they're not shown in nav?

    Thanks again,

    Galen

  5. 6 Posted by John Nunemaker on 25 Feb, 2010 03:38 AM

    John Nunemaker's Avatar

    Yep, see "children":
    http://docs.harmonyapp.com/harmony-templates/objects/#object-page

    <http://docs.harmonyapp.com/harmony-templates/objects/#object-page>You do
    need pages published, I would just uncheck the show in navigation box.

  6. 7 Posted by John Nunemaker on 25 Feb, 2010 03:39 AM

    John Nunemaker's Avatar

    Also, I would only store configuration things in pages that need to be
    client editable. Something like a google analytics code, I would put in an
    include and just include that in the footer of each template.

  7. Support Staff 8 Posted by Steve Smith on 25 Feb, 2010 03:39 AM

    Steve Smith's Avatar

    There's the item_from_path filter: http://docs.harmonyapp.com/harmony-templates/filters/object-filters/#object-item_from_path

    Use it like this to get the home page.

    {{ '/' | item_from_path | assign_to: 'home' }}

    Then you can use {{ home.data.whatever }}

  8. 9 Posted by Jonathan Hoyt on 29 Nov, 2010 09:28 PM

    Jonathan Hoyt's Avatar

    Closing for now, will update when I have something better to tell.

Comments are currently closed for this discussion. You can start a new one.

Recent Discussions

17 May, 2012 10:45 PM
20 Mar, 2012 05:05 PM
26 Apr, 2012 01:40 AM
07 Mar, 2012 04:42 PM