Forum for discussing general topics related to Couch.
22 posts Page 2 of 3
tim wrote: What about creating a separate template, dynamic_folder_data.php. Make it clonable and add any sort of editable regions you want. Now whenever you create a new dynamic folder, you also create a corresponding page in the new template to hold it's data.

I'm not entirely clear on how you're using the dynamic folders or the editable regions you want for them, but this is how I might do it.

I've played with the dynamic folders just once. The ability to add an image and description to a folder is a nice touch. But then I almost immediately felt hungry for more. A nice feature for dynamic folders might be to add the ability to customize the editable regions for a folder. Maybe something like a folder_data tag that could be wrapped around a group of editable regions to hold folder data.


I've considered this approach, but I don't think it will work. I need a way to associate the two different templates. Really want to avoid weird workarounds if possible.
@cardmaverick,

As @Tim suggested, you should use a separate template to hold custom data for the folders.
The idea is this -

Let us say template_a has three folders named 'cat-1', 'cat-2' and 'cat-3'.
Since we cannot store arbitrary amount of custom data with folders, we use another template, say named 'template_b' for this purpose.
Define any number of editable regions in the template.

For each folder in template_a, create a corresponding cloned-page in template_b (i.e create pages named 'cat-1', 'cat-2' and 'cat-3' in template_b).

The relation between the folders of template_a and their corresponding pages in template_b is the common name.

On the front-end, while displaying a folder of template_a, we can easily search for a page in template_b with the same name and display its contents -
For example we can place the following code in template_a -
Code: Select all
<cms:if k_is_folder>
   <!-- we are in folder-view of template_a -->

   <!-- search for its corresponding page in template_b -->
   <cms:pages masterpage='template_b.php' page_name=k_folder_name limit='1'>
      ... use page's data ..
   </cms:pages>

</cms:if>

The vital part of the code above is the page_name=k_folder_name statement where the k_folder_name variable holds the template_a folder's name and we use it to get the page from template_b.

In fact, this very technique is used in our Aurelius tutorial where we use custom descriptions for portfolio folders (back then folders did not have the image and desc field). Please see http://www.couchcms.com/docs/tutorials/ ... folio.html.

I am sure you won't find this too cumbersome - you are likely to have only a finite number of folders.

Hope this helps.
Thanks for the formula KK :)
Hi.
I just wanted to confirm that this method can be used with couchs new gallery feature to add unique fields to each gallery. In fact, I need to combine this with a sort of tag feature listed here http://www.couchcms.com/forum/viewtopic.php?f=4&t=7990&hilit=dropdown+gallery because I need each folder to be related to a thing, in this case a person. Can you please tell me if using these two solutions together will work for my uses or guide me how to do this.

To reiterate, I will use the gallery feature then create another dynamic folder with the same as each galleries dynamic folder name to hold the custom data. With this other dynamic folder I will include a tag with using relations where the tags/person can be entered along with some other miscellaneous custom data. Because I do want the user to have a drop-down box that to choose the tag/person selection.

Thanks in advance.
Lots of style and minimal fuss, if only everyday could be that easy.
Hi siliconpoetry,

If I understood it right, you wish to follow the recipe detailed in this thread but 'relate' the proxy cloned pages to other pages (using the relations feature).

Yes, I think there should be no problem. The code snippet given above could be modified to show the related pages as follows
Code: Select all
<cms:if k_is_folder>
    <!-- we are in folder-view of template_a -->

    <!-- search for its corresponding page in template_b -->
    <cms:pages masterpage='template_b.php' page_name=k_folder_name limit='1'>
   
        ... use page's data ..


        <!-- get the related pages if this page -->   
        <cms:related_pages 'name_of_the field' >
            <!-- All variables of the related pages are available here -->
            <cms:show k_page_title /><br/>
        </cms:related_pages>

    </cms:pages>

</cms:if>

Hope this helps.
Thanks for the reply. I am a little confused as to the solution above but it's late at night.

I am trying to get this to work now that I see how to use relations hands on. I am using the Photo Gallery example from the documentation. I apologize if you misunderstood, in the original post I thought folders was a underlying construct of the Photo Gallery. With the Photo Gallery I CAN add further data to the gallery items so each image has added fields which is what I want. I haven't tried yet but I think in the above example you were talking about the actual top level folders(I may need to do this).

Thus far I have added relations to my "primary" page so that each image has a relation to another template:
Code: Select all
<cms:editable type='relation' name='Exhibitions' masterpage='exhibitions.php' reverse_has='one' />

I can then call get data from the exhibitions.php when it is associated with a image.
Code: Select all
<cms:show k_page_title /><br/><cms:show exhibition_location />


I am having trouble getting the images associated with an exhibition in my exhibitions page. I have tried both the method above and the method shown in the documentation (relations) to no avail. Could you give me the related <cms:reverse_related_pages > code to use in my non-primary relations page. Thanks in advance.
Lots of style and minimal fuss, if only everyday could be that easy.
Hi siliconpoetry,

So your basic requirement is to relate two templates, 'exhibitions.php' and 'gallery.php', where each exhibition can contain many photos. Right?

If so, I think you'll find the ready-made solution described in the following thread useful -
viewtopic.php?p=16293#p16293

In the mentioned thread the two templates are products.php and gallery.php. Please substitute 'products.php' with 'exhibitions.php' and you should get what you are looking for.

Does this help?
I don't think the above solution is what I want. One reason is I actually have 2 relations defined in the gallery page. One for exhibitions another for collectors, each one needs to include images from the art gallery. So I want to retain the default functionality of the relations such as drop-down/checkbox's for exhibitions and collectors in the gallery. Like I said before I can add the relations and get the related pages information from the primary gallery. However, I cannot get which primary gallery images are related to exhibitions and collectors from their respective templates nor can I access the data (ie thumbnails, full-size img). Please help! How do I access the primary gallery's information from the related templates.
The code in the art gallery page is like so:
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='500'
      height='500'
      show_preview='1'
      preview_height='200'
      type='image'
   />
   
   <cms:editable
      name='gg_thumb'
      label='Image Thumbnail'
      desc='Thumbnail of the main image above'
      width='115'
      height='115'
      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='100'
      height='100'
      assoc_field='gg_image'
      show_preview='1'
      type='thumbnail'
   /> 
   
   <cms:editable
      name='my_desc'
      label='Description'
      height='60'
      type='textarea'
   />
   
   <cms:editable type='relation' name='Collectors' masterpage='collectors.php' reverse_has='one' />
   <cms:editable type='relation' name='Exhibitions' masterpage='exhibitions.php' reverse_has='one' />
   
</cms:template>

With the code below in exhibitions.php the dump showed the relations fields but the data was empty. This is the part I need help on.
Code: Select all
<cms:pages masterpage='art.php' limit='1'>
    <cms:dump/>
        ... use page's data ..


        <!-- get the related pages if this page -->   
        <cms:reverse_related_pages 'Exhibitions' masterpage='art.php'>
            <!-- All variables of the related pages are available here -->
            Test (this code does not get rendered no matter what I do)
            <cms:dump/>
            <cms:show k_page_title /><br/>
        </cms:reverse_related_pages>

    </cms:pages>
Lots of style and minimal fuss, if only everyday could be that easy.
@siliconpoetry

So pages of gallery (i.e. images) are related to exhibitions and collectors.
Can you please answer a few questions regarding that setup?

Am I right in assuming the following? -
1. An image (i.e. a gallery page) can belong to only one exhibition.
2. The same image above can belong to only one collector.
3. Each exhibition and collector can have multiple images.

Please confirm and we can then move to concrete code.

Thanks.
Hi.
1) I am not 100% positive because the client has not specified this yet. However, I would like to allow a gallery image to belong to more than one exhibition because paintings(images) may belong to past exhibitions and current exhibition. Note, in the example I posted I set it as a many-to-one relationship but in the final site the requirement will be as mentioned in italics.
2) Yes, a image can belong to only one collector
3) Yes, each exhibition and collector can have multiple related images.

Thanks, I am already pleased with how couch handles relations. So perfect. Once we get the next part working it's 110%.
Lots of style and minimal fuss, if only everyday could be that easy.
22 posts Page 2 of 3
cron