1

Building a photography website for a client, need a way to bulk upload images, much like using the assets field. I want these to be grouped into different sets by entry or category. So that I can apply whatever fields I need to the set then loop through these images based on set in the Front-End.

The method I have tried is using entries and having an assets field to upload the images. The problem I am having is I also need to have each image generate it's own seperate URL, meaning a template page for the set of images and then another template for each image in that set.

Is there a way to accomplish this using Craft's core features?

2

In your main image index template, you can iterated through all of the assets and generate URLs yourself like this:

{% for asset in assets %}
    <a href="/photos/photo-detail/{{ asset.slug }}">{{ asset.title }}</a>
{% endfor %}

Then set up a custom route for /photos/photo-detail/(slug) and point it at the photo-detail.twig template. In that template, you can get the slug for the asset via craft.request.getSegment(3) and then look up the asset via the slug.

  • This has worked perfectly, I see now how you can use routes and Twig together to get alot done. Very powerful stuff. Thanks!! – dannyryuk Dec 30 '16 at 13:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.