1–n file attachments
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
Comments are currently closed for this discussion. You can start a new one.
2 Posted by John Nunemaker on 25 Feb, 2010 03:06 AM
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.
3 Posted by Galen King on 25 Feb, 2010 03:20 AM
Cool. Awesome. Thanks.
Support Staff 4 Posted by Steve Smith on 25 Feb, 2010 03:20 AM
For now, you could do this one of two ways:
Simply place the max number of banner images as template data (eg. 5 max images, create 5 individual image uploads).
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.
5 Posted by Galen King on 25 Feb, 2010 03:29 AM
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
6 Posted by John Nunemaker on 25 Feb, 2010 03:38 AM
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.
7 Posted by John Nunemaker on 25 Feb, 2010 03:39 AM
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.
Support Staff 8 Posted by Steve Smith on 25 Feb, 2010 03:39 AM
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 }}
9 Posted by Jonathan Hoyt on 29 Nov, 2010 09:28 PM
Closing for now, will update when I have something better to tell.