Problems, need help? Have a tip or advice? Post it here.
10 posts Page 1 of 1
Hello everybody,

here is what i wanna do: I am setting up a Blog with clonable template. This template has a text and an image area, like in the tutorial. But instead of a single picture I need a gallery for each blog entry. So I replace the image with the gallery template (http://www.couchcms.com/docs/concepts/p ... llery.html):
Code: Select all
<cms:template title='Post' clonable='1'>
        <cms:editable name='post_content' label='Content' desc='Write down all content information here' type='richtext' />
        <cms:template title='post_gallery' clonable='1' dynamic_folders='1' gallery='1'>
                <cms:editable name='gg_image' label='Image' desc='Upload your main image here' width='500' show_preview='1' preview_height='200' type='image' />
                <cms:editable name='gg_thumb' label='Image Thumbnail' desc='Thumbnail of image above' width='115' height='115' enforce_max='1' type='thumbnail' />
        </cms:template>
</cms:template>


In the admin panel I get a big mess instead of a Blogpanel, where every Blogentry has their own gallery menu. Can you help me?
Hello and welcome, whoem,

I see you are trying to 'nest' two templates. This, unfortunately, won't work.

For now to have a gallery per page we have two choices -
1. Use repeatable-regions (and manually add images)

2. To bulk upload images - use a separate gallery template with dynamic folders.
For each page in the main template, create a folder in the gallery template with the same name. This 'same name' property can be used in page-view of the main template to list images from same named folder of the gallery template.
Somewhat hackish but works.

Hope this helps.
Here are some details to help you create a gallery per page using the second method mentioned above (i.e. matching folder names) -

Let us assume your main template is 'products.php' and that it has two cloned pages with names (NOT titles, mind you) 'product-one' and 'product-two'.

Create a template for gallery and name it, for example, 'gallery.php' .
In this template create two 'folders' named - 'product-one' and 'product-two'. As you can see, the folder names match the page names of the main template.

Now suppose if we place the following code in 'products.php' page-view (i.e. when visiting one its cloned pages)-
Code: Select all
<cms:pages masterpage='gallery.php' folder='product-one' >
   ... images from gallery folder 'product-one'will be fetched here..
</cms:pages>

- you can see that images from folder named 'product-one' of gallery template will get listed. Since we have explicitly stated folder='product-one' it is only this folder that will get listed on every product page.

If we simply change that parameter to folder=k_page_name , the name of the current product page being viewed will be used instead of the hard-coded value -
Code: Select all
<cms:pages masterpage='gallery.php' folder=k_page_name >
   ... images from gallery folder that matches the currently viewed pages will be fetched here..
</cms:pages>

And that should show the folder that matches whatever page we are on.

Hope this helps.
I tried it, but it is not working. My main .php-File beginning looks like:
Code: Select all
<?php require_once( 'astra/cms.php' ); ?>
<cms:template title='Pages' clonable='1'>
        <cms:editable name='post_content' label='Content' desc='Write down all content information here' type='richtext' />
        <cms:editable name='post_image' label='Image' desc='Upload your Image here'  type='image' />
        <cms:pages masterpage='gallery.php' folder='product-one' />
        <cms:folder name="anim" title="Animation" />
        <cms:folder name="illu" title="Illustration" />
        <cms:folder name="inst" title="Installation" />
        <cms:folder name="gif" title="GIF" />
</cms:template>


I made a file named gallery.php that looks like:
Code: Select all
<?php require_once( 'astra/cms.php' ); ?>
<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"
      show_preview='1'
      preview_height='200'
      type="image"
   />

   <cms:editable
      name="gg_thumb"
      assoc_field="gg_image"
      label="Image Thumbnail"
      desc="Thumbnail of image above"
      width='115'
      height='115'
      enforce_max='1'
      type="thumbnail"
   />

   <cms:folder name='page-one' title='page-one' />
   <cms:folder name='page-two' title='page-two' />

</cms:template>

<?php COUCH::invoke(); ?>


I refreshed both the .php-Files in Browser. But when I create a Pages with the names of the Gallery Folders I still dont see a Gallery Menu in my Page-Template :(
Please try this -
Code: Select all
<?php require_once( 'astra/cms.php' ); ?>
<cms:template title='Pages' clonable='1'>
        <cms:editable name='post_content' label='Content' desc='Write down all content information here' type='richtext' />
        <cms:editable name='post_image' label='Image' desc='Upload your Image here'  type='image' />
       
        <cms:folder name="anim" title="Animation" />
        <cms:folder name="illu" title="Illustration" />
        <cms:folder name="inst" title="Installation" />
        <cms:folder name="gif" title="GIF" />
</cms:template>

<cms:if k_is_page>
    <cms:pages masterpage='gallery.php' folder=k_page_name >
        <img src="<cms:show gg_thumb />" /><br/>
    </cms:pages>
</cms:if>
I got the concept now - thank you a lot, especially for your final answer! It works now. I am so happy now. And just mind: tomorrow is Sunday! Have a nice weekend :D
After this big progress unfortunately another wild problem appeared:
In my list-view snippet I put all the dynamic content inside a
Code: Select all
<cms:pages masterpage='myPageTemplate.php'> ... </cms:pages>
container. My list-view is an index of simple page-preview-pins. Each pin shall contain the main image of its pages gallery. Now have to refer to the gallery with a
Code: Select all
<cms:pages masterpage='gallery.php'>
tag inside the cms:pages tag pointing to my page template. But that's somehow causing a glitch. Not working as imagined. I guess, I barked up the wrong tree again...

How can I give something like a "main image" attribute to one of the pictures inside a gallery-folder? And how can I make it visible in my list-view?

Would be glad, if you could give me some tailwind once again :) Thank you.
Hi,

It is perfectly alright to nest multiple cms:pages. The only glitch could be that the variables of inner loop are overshadowing the variables of same name in the outer loop.

Can you please post in the relevant code in full here?
Hopefully we'll be able to spot the problem.

Thanks
Code: Select all
            <cms:pages masterpage='index.php' >
            <cms:if k_page_foldertitle>
               <cms:set my_category=k_page_foldertitle />
            <cms:else />
               <cms:set my_category='Random' />
            </cms:if>

               <div class="pin" data-category="<cms:show k_page_foldername />">
                  <a class="pinWrapper" href="<cms:show k_page_link />">
                     <div class="pinCategory"><cms:show my_category /></div>
                     <h3 class="pinTitle"><cms:show k_page_title /></h3>
                     <cms:pages masterpage='gallery.php' folder=k_page_name >
                        <img class="pinImage" src="<cms:show k_page_folderimage />" />
                     </cms:pages>
                  </a>
               </div>
            </cms:pages>


The output in my list-view is, that for each pin the script inserts the right k_page-folderimage. But it shows each folderimage as often, as the overall amount of pictures inside the folder. But I want only one image each pin. Here is how it looks right now: http://whoem.bootes.uberspace.de/andersen/index.php
Hi, please use the 'limit' parameter to make the inner cms:pages tag loop only once -
<cms:pages masterpage='gallery.php' folder=k_page_name limit='1'>

Hope this helps.
10 posts Page 1 of 1
cron