Forum for discussing general topics related to Couch.
22 posts Page 3 of 3
Thanks.

Assuming the names of the three related templates are - gallery.php, exhibitions.php and collectors.php, following is what you should do.

Define the following regions in gallery.php
Code: Select all
<cms:editable type='relation' label='Exhibitions' name='image_exhibitions' has='many' masterpage='exhibitions.php'  />

<cms:editable type='relation' label='Collectors' name='image_collectors'  has='one' masterpage='collectors.php' />

While editing an image (gallery page), you should now see a multi-select checkboxes list for exhibitions and a single-select dropdown for collectors.

To display the related pages on the various templates, following sample code should help you -

gallery.php:
Code: Select all
<cms:if k_is_page >
    <!-- All variables of 'gallery.php' are available here -->
    <h2>Image: <cms:show k_page_title /></h2>
   
    <h3>Related exhibitions:</h3>
    <cms:related_pages 'image_exhibitions' >
        <!-- All variables of 'exhibitions.php' are available here -->
        <cms:show k_page_title /><br/>
    </cms:related_pages>
     
    <h3>Related collectors:</h3>
    <cms:related_pages 'image_collectors' >
        <!-- All variables of 'collectors.php' are available here -->
        <cms:show k_page_title /><br/>
    </cms:related_pages>
       
</cms:if>

exhibitions.php:
Code: Select all
<cms:if k_is_page >
   <!-- All variables of 'exhibitions.php' are available here -->
   <h2>Exhibition: <cms:show k_page_title /></h2>
   
   <h3>Related images:</h3>
   <cms:reverse_related_pages 'image_exhibitions' masterpage='gallery.php' >
      <!-- All variables of 'gallery.php' are available here -->
      <cms:show k_page_title /><br/>
   </cms:reverse_related_pages>
</cms:if>

collectors.php
Code: Select all
<cms:if k_is_page >
   <!-- All variables of 'collectors.php' are available here -->
   <h2>Collector: <cms:show k_page_title /></h2>
   
   <h3>Related images:</h3>
   <cms:reverse_related_pages 'image_collectors' masterpage='gallery.php' >
      <!-- All variables of 'gallery.php' are available here -->
      <cms:show k_page_title /><br/>
   </cms:reverse_related_pages>
</cms:if>

Hope it helps.
Hi KK,
I am still unable to get the related gallery images to show on my exhibitions and collectors page. The page will just not render anything with reverse_related_pages. Also, please note the gallery page is named art.php with the title "Gallery". What is going on here?

Here is the code dump, also it seems that k_is_list is set to 1 while k_is_page is 0;

EDIT: Finally figured out the issue, the k_is_page only validates to true when I am in a cloned page view from exhibitions and collectors. DUH!. Now it is working flawlessly, until my next roadblock I suppose. :lol:

art.php
Code: Select all
<cms:template title='Gallery' clonable='1' dynamic_folders='1' gallery='1'>
   <cms:editable
      name='gg_image'
      label='Image'
      desc='Upload your main image here'
      width='1400'
      height='1400'
      show_preview='1'
      preview_height='200'
      type='image'
   />
   
   <cms:editable
      name='gg_thumb'
      label='Image Thumbnail'
      desc='Thumbnail of the main image above'
      width='150'
      height='150'
      enforce_max='1'
      assoc_field='gg_image'
      show_preview='1'
      type='thumbnail'
   /> 

   <cms:editable
      name='my_thumb_2'
      label='Image Thumbnail 2'
      desc='Second thumbnail of the main image above'
      width='150'
      height='150'
      assoc_field='gg_image'
      show_preview='1'
      type='thumbnail'
   /> 
   
   <cms:editable
      name='my_desc'
      label='Description'
      height='60'
      type='textarea'
   />
   
   <cms:editable type='relation' label='Exhibitions' name='image_exhibitions' has='many' masterpage='exhibitions.php'  />

   <cms:editable type='relation' label='Collectors' name='image_collectors'  has='one' masterpage='collectors.php' />
   
</cms:template>

art.php body
Code: Select all
<cms:if k_is_list >
     
      <!-- gallery folders -->
      <cms:set my_page="<cms:gpc 'pg' method='get' />" />
      <cms:if my_page lt '2' >
         <ul class="portfolio-series">
            <cms:folders childof=k_folder_name hierarchical='1' depth='1'>
           
               <cms:set my_folder_image="" />
               <cms:if k_folder_image>
                  <cms:set my_folder_image=k_folder_image />
               <cms:else />
                  <cms:pages folder=k_folder_name include_subfolders='0' limit='1'>
                      <cms:set my_folder_image=my_thumb_2 scope='parent' />
                  </cms:pages>
               </cms:if>
               <cms:if my_folder_image=''><cms:set my_folder_image="<cms:show k_admin_link />theme/images/empty-folder.gif" /></cms:if>
               
               <li><a href="<cms:show k_folder_link />">
                      <div class="gallery-top"><img alt="<cms:show k_folder_title />" src="<cms:show my_folder_image />" width="150" height="150"/></div>
                      <div>
                     <cms:show k_folder_title /><br/>
                     <cms:show k_folder_totalpagecount /> images<br/>
                     <cms:show k_folder_totalchildren /> folders<br/>
                      </div>
                 </a>
               </li>
            </cms:folders>
         </ul>   
      </cms:if>
     
      <!-- gallery images-->
      <ul class="gallery">
         <cms:pages folder=k_folder_name include_subfolders='0' limit='18' paginate='1'>
            <li><a href="<cms:show gg_image />" title="<cms:show k_page_title />">
                <div class="gallery-top"><img alt="<cms:show k_page_title />" src="<cms:show my_thumb_2 />" width="150" height="150"/>
                </div>
                    <div><cms:show k_page_title /><br/><cms:show my_desc /><br/>
                    <cms:related_pages 'image_exhibitions' >
                    <!-- All variables of 'albums.php' are available here -->
                    <cms:show k_page_title /><br/><cms:show exhibition_location />
                    </cms:related_pages>
                    </div></a>
                </li>
            <cms:if k_paginated_bottom ><!-- pagination -->
               <div id="paginator" style="clear:both"><cms:paginator /></div>   
            </cms:if>
           
         </cms:pages>
      </ul>
 
   <cms:else /><!-- k_is_page -->   
     
      <div id="image_container">
         <img alt="<cms:show k_page_title />" src="<cms:show gg_image />"/>
      </div>
     
   </cms:if>

exhibitions.php
Code: Select all
<cms:template title='Exhibitions' clonable='1' > 
<cms:editable
name='exhibition_name'
label='Name'
desc='Enter title of exhibition here'
type='text'/>
<cms:editable
name='exhibition_location'
label='Location'
desc='Enter Venue here'
type='text'/>
<cms:editable
name='exhibition_address'
label='Address'
desc='Enter address here'
type='text'/>
</cms:template>

exhibitions.php body
Code: Select all
<cms:if k_is_page >
   <!-- All variables of 'exhibitions.php' are available here -->
   <h2>Exhibition: <cms:show k_page_title /></h2>
   
   <h3>Related images:</h3>
   <cms:reverse_related_pages 'image_exhibitions' masterpage='gallery.php' >
      <!-- All variables of 'gallery.php' are available here -->
      <cms:show k_page_title /><br/><cms:show gg_image />
   </cms:reverse_related_pages>


collectors.php
Code: Select all
<cms:template title='Collectors' clonable='1' > 
<cms:editable
name='collector_name'
label='name'
desc='Enter name of collector here'
type='text'/>
<cms:editable
      name='my_desc'
      label='Description of collector'
      height='60'
      type='textarea'
/>
</cms:template>

collectors.php body
Code: Select all
 <cms:if k_is_page >
   <!-- All variables of 'collectors.php' are available here -->
   <h2>Collector: <cms:show k_page_title /></h2>
   
   <h3>Related images:</h3>
   <cms:reverse_related_pages 'image_collectors' masterpage='gallery.php' >
      <!-- All variables of 'gallery.php' are available here -->
      <cms:show k_page_title /><br/>
   </cms:reverse_related_pages>
</cms:if>
Lots of style and minimal fuss, if only everyday could be that easy.
22 posts Page 3 of 3
cron