I am using the technique described here https://www.couchcms.com/docs/advanced-tutorial/list-view.html to allow sorting of tracks by title or date. The sorting functionality is working. My problem lies with the retrieval, capture and display of the data.

I have relationships set up between tracks.php, albums.php and composers.php:

in albums.php:
Code: Select all
    
<cms:editable
        type='reverse_relation'
        name='album_tracks'
        masterpage='tracks.php'
        field='tracks_albums'
        anchor_text='&blacktriangleright; link to album tracks'
        label='CLICK ON THE LINK BELOW TO GO TO THE TRACKS TEMPLATE'
        desc=''
   
    />
   
</cms:editable>
    <cms:editable
        type='relation'
        name='album_composer'
        masterpage='composers.php' 
        label='Composers'
    /> 


and in tracks.php:

Code: Select all
    <cms:editable 
        type='relation'
        name='tracks_albums'
        masterpage='albums.php'
        has='one'
        no_gui='1'
        label='&nbsp;'
    />


In tracks.php I have some nested cms:pages / cms:related_pages / cms:reverse_related_pages to get the data that I need to display on the tracks listing page. However I need to display the data from tracks.php, albums.php and composers.php in a particular way so am trying to save the fields I want (using cms:set) so that I can output the fields in the required style/layout. I have a problem with the following code (the code below is for the display of tracks sorted by date, hence I am accessing the tracks via albums.php because this is where the date is set up - for sorting by track title the code is slightly different, but I get the same problem described below):

from tracks.php:

Code: Select all
<cms:capture into='my_content' >        
<th class="note">
    Track title
    <a href="<cms:add_querystring k_page_link 'sort=title' />" class="sort_arrow" >&uarr;</a>
    <a href="<cms:add_querystring k_page_link 'sort=-title' />" class="sort_arrow" >&darr;</a>
</th>
<th class="date">
    Track date
    <a href="<cms:add_querystring k_page_link 'sort=date' />" class="sort_arrow" >&uarr;</a>
    <a href="<cms:add_querystring k_page_link 'sort=-date' />" class="sort_arrow" >&darr;</a>
</th>         
   
<cms:embed 'handle-sort-tracks.html' />         
            <cms:pages masterpage='albums.php' orderby=my_album_sort_field order=my_album_sort_dir>
               
                   <cms:set my_album_title=k_page_title/>
                   <cms:set my_album_date=album_date/>
                   
                <cms:related_pages 'album_composer' masterpage='composers.php' >
                   <cms:set my_composer=k_page_title/>
                </cms:related_pages>               

                <cms:reverse_related_pages 'tracks_albums' masterpage='tracks.php'  orderby='page_title' order='asc'>                   
                   <cms:set my_track_title=k_page_title/>
                </cms:reverse_related_pages>   
           
            </cms:pages>
               
                <cms:show my_track_title/>
               <cms:show my_composer/>
               <a href="<cms:show k_page_link />"><cms:show my_album_title/></a>
               <cms:show my_album_date/>
   
</cms:capture>   
<cms:show my_content/>


The problem is that the data in my_track_title and my_composer does not show up with <cms:show my_content/> - I only have my_album_title and my_album_date

Am I attempting something that can't be done or perhaps doing it the wrong way?!