0

My goal is to ensure uploaded videos are organized into folders like:

/Show/Season/Episode/videofile.mp4 

Or stated another way...

/{{ Show ID of grandparent }}/{{ Season ID of parent }}/{{ Episode ID of parent}}/videofile.mp4

I understand we can use twig tags to dynamically control the subfolder names, but since our Videos entries are related children of Episodes, which is a child of Seasons, which is a child of Shows, how do I ensure these values are used in the path? As it stands I've organized these as separate sections, where entry fields are used to select the children (Seasons, Episodes, videos). But I'm questioning whether this should be collapsed into one Shows section with a matrix for including Seasons, Episodes, and Videos.

Using Craft 4

1 Answer 1

1

I'm not sure of your exact setup, but you can get the relationships dynamically and make them part of your dynamic subpath.

Let's assume you have the following channel sections:

  • Episodes
  • Seasons
  • Shows

In the field layout for Episodes, you have an Entries field, where you choose which season it belongs to, and an Assets field, where you upload the video file.

The Season entry (e.g., Season 1) has a Show Entries field where you relate the show.

When you create a new episode, you choose the season and get the show automatically based on the season's relationship to it, and you upload a video file for that episode.

With that setup, you can input some Twig code in the Default Upload Location to create a dynamic subpath of show/season/episode like this (I'm using slugs instead of IDs):

{{ object.season.one().show.one().slug }}/{{ object.season.one().slug }}/{{object.slug}}

how path looks in Assets sidebar

1
  • Thank you for taking the time! This is exactly what I needed. I'm a former CQ subscriber, and hope to be again soon.
    – Jim
    Commented Nov 18, 2022 at 15:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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