Problems, need help? Have a tip or advice? Post it here.
4 posts Page 1 of 1
EDIT: I tried to delete the posting, because after further thought it is possible that an album will have tracks by different composers - so setting up composer for each track is a GOOD thing!

I'm wondering if this is possible - it is a new question in connection with my previous posting - https://www.couchcms.com/forum/viewtopic.php?f=4&t=11214

I have set up the templates for tracks.php and albums.php as suggested by KK - with a many to one relationship, and I like how this presents in the Admin Panel - very clear and easy for the client to set up an album and its associated tracks.

I have another template called composer.php with a many to many relationship to albums.php to enable the client to select a composer when creating a new album.

The workflow is: 1. create a composer 2. create an album and select composer(s) from the list 3. create the tracks for the album.

However, there is also a requirement to list tracks by composer and I'm not sure how to most effectively and efficiently do this. I thought I would use the cms:pages tag to list all tracks by a composer:
Code: Select all
<cms:pages masterpage='tracks.php' custom_field='track_composer==<cms:show composer_name />'></cms:pages>

Clearly, this requires that each track has the composer set up as an editable field. I know that I could create a many to many relationship between tracks.php and composer.php (a track could have more than one composer) - as I have already created between albums.php and composer.php - but that would require the client to select the composer for the album and then for each album track he would have to select the composer again. This seems a bit repetitive and user-unfriendly (e.g. if he made a mistake with the composer - it would require changing in several places rather than just a single place).

The albums.php cloned page is created with a relationship to one or more of the cloned pages of composers.php. The next step is to create cloned pages of tracks.php with a many to one relationship to albums.php - is there any way of getting hold of the composer info at this stage and auto-populating an editable region composer_name in tracks.php or creating a relationship between tracks.php and composer.php?

I hope my question is clear! And thanks for any advice forthcoming ...
Composer editable might become an un-filled relational editable in tracks.php - to hold exceptional cases, where composer for that track should be different from the rest of the album. So, when listing tracks in front-end - take the composer from the album's relation to composers and if track's relation to composer is set to some non-zero value then show that relation instead of default value.
It is not necessary then, to fill up composer for each track. Fill only for those tracks which have different value than the album itself.

In the end you'd have
composers.php
albums.php with relation to composers.php and reverse_relation to tracks.php
tracks.php with relation to albums.php and relation to composers.php
thanks for your response Trendoman ... I'm struggling with this - If no relationship is created between composer and track and a composer can have multiple albums I'm not sure how I can link everything together i.e. how I can list all tracks by composer
EDIT: after some extensive trials and errors I may have progressed a little further with some nesting of relations ....
potato wrote: If no relationship is created between composer and track and a composer can have multiple albums I'm not sure how I can link everything together

If you know a composer, then find all ids of albums related to composer, then list tracks that relate to those albums.
Think of some concept where you don't need to link everything to everything to find where it is stored - a dog in a car, a car in the garage -> means also the dog in the garage, but no direct relation between those 2. Value of composer for each track is set implicitly, via album, not explicitly via editable.

If some track does need to have a different composer as you said before, then we can set a relation only for that track, to override default setting. In admin panel it would look like a relation editable in tracks.php, set to a different composer, while the rest of the tracks of the same album will still have this new editable not set (and have therefore implied value).

Did you study all relationships examples? Check viewtopic.php?f=5&t=8581&p=16352#p16352 Once you need to list tracks, I think what you look for are Composite queries from that long post.
4 posts Page 1 of 1

Who is online

In total there are 4 users online :: 0 registered, 0 hidden and 4 guests
(based on users active over the past 5 minutes)

Users browsing this forum: No registered users and 4 guests

cron