Problems, need help? Have a tip or advice? Post it here.
8 posts Page 1 of 1
Hi!
I'm editing an already existing site. It is in 5 languages, and all the repeating elements are just copied in the code, there is no such thing as using snippets etc on the website.
So now i have a gallery that i need to insert into 5 different pages (because the menu is 5 languages, and i'm too unexperienced to change that myself on the fly).
So how do i insert the gallery? Without creating 5 identical galleries, i mean :lol:

I'm generally not very good with understanding how to use the gallery, so my code wouldn't be of any use: i'm ready to rewrite it from scratch if there is any solution!

please help.....
Hi,

I am not sure how the multi-lingual part has been implemented in your site but chances are that you have a separate template for each language.

If that is correct them you should first implement the gallery completely on one single template (i.e. language).
Let us assume this template is named 'en/gallery.php'.

Once that is done, you'll find that the code in that template that lists out the gallery images goes something like this -
Code: Select all
<cms:pages ..

In all the remaining four templates you can simply use the same code as above with just one minor change - you'll need to instruct the cms:pages tag to fetch images from the first template. We do that using the 'masterpage' parameter as follows -
Code: Select all
<cms:pages masterpage='en/gallery.php' ..

So basically, you'll be creating the gallery (i.e. defining the gallery editable regions and also uploading the images) in one template only. Then in the other template you list the images from the first template.

Hope this helps.
Oh wow, that really works!
How did i not think of it myself!

But then the next thing are the folders...
I have folders and subfolders, and with the offered solution they are opening in the original template.
I mean if the original is in de/gallery.php, and another one, with the masterpage parameter, is in en/gallery.php, then when i open a folder in en, it redirects me to de/gallery.php?f={number}.

Any ideas how to manage that?

Here is my code, if it is of any use:
Code: Select all
 <cms:breadcrumbs separator='&nbsp;>&nbsp;' include_template='1' />

<!--Folders buttons-->
   <cms:folders masterpage='gallery.php' childof=k_folder_name  depth='1'>
      <cms:set my_folder_image=k_folder_image />
      <cms:if my_folder_image=''><cms:set my_folder_image='couch/theme/images/empty-folder.gif' /></cms:if>

      <a href="<cms:show k_folder_link />" class='gsubfolder'>
         <img src="<cms:show my_folder_image />"><br>
         <cms:show k_folder_title />
      </a>
   </cms:folders>
<br>
<!--Images-->
      <cms:pages masterpage='gallery.php' folder=k_folder_name include_subfolders='0' >
      <a class=”shutterset” href="<cms:show gg_image/> "><img src="<cms:show gg_thumb/>" /></a>
      </cms:pages>
Folders are template-specific so, I am sorry, but for your solution to work you'll have to create the same set of folders in all the 5 templates - please keep in mind that names of the folders should be exactly the same.

Let us assume 'de/gallery.php' is the original template containing all the images and the en/gallery.php is one of the other templates. If you were to create in 'en/gallery' exactly the same folders as in the original template, then the following code should work as if these folders really contained the images from the original template -
Code: Select all
<cms:breadcrumbs separator='&nbsp;>&nbsp;' include_template='1' />

<!--Folders buttons-->
   <cms:folders masterpage='en/gallery.php' childof=k_folder_name  depth='1'>
      <cms:set my_folder_image=k_folder_image />
      <cms:if my_folder_image=''><cms:set my_folder_image='couch/theme/images/empty-folder.gif' /></cms:if>

      <a href="<cms:show k_folder_link />" class='gsubfolder'>
         <img src="<cms:show my_folder_image />"><br>
         <cms:show k_folder_title />
      </a>
   </cms:folders>
<br>
<!--Images-->
      <cms:pages masterpage='de/gallery.php' folder=k_folder_name include_subfolders='0' >
      <a class=”shutterset” href="<cms:show gg_image/> "><img src="<cms:show gg_thumb/>" /></a>
      </cms:pages>

Please notice above that the <cms:folder> is listing folders of 'en/gallery.php' while the <cms:pages> showing the images is actually listing images from the main template 'de/gallery.php'. This will work because the 'k_folder_name' would be the same for both the templates.

Hope it helps.
well this got me confused now...

i've tried out your solution, and at first it worked, but then not any more, it seems to have stopped for no reason! :(

the copied page (english one) just doesn't show any folders any more.
i have a picture in the gallery outside of folders - it is being shown.
everything is how it should be, but no traces of any folders.

i decided to try again, start fresh and create a test gallery. i've cut down it's code to the minimum, to make sure that no other stuff interferes or anything. no results, i don't understand. i've tried lots of different things, but no folders are available at the second language pages.
i checked a hundred times that the folder names are exactly the same.

i don't know, it seems hopeless.

here are the test gallery templates:
Code: Select all
<?php require_once'../couch/cms.php'; ?>
<cms:template title='gal' 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='100'
      height='100'
      type="thumbnail"
     show_preview='1'
   />
</cms:template>
<!DOCTYPE html>
<html>
<head></head>
<body>
<!--Folders-->
   <cms:folders masterpage='all/gal.php'>
         <cms:show k_folder_title />
   </cms:folders>
<!--Images-->
      <cms:pages masterpage='all/gal.php'>
<img src="<cms:show gg_thumb/>" />
      </cms:pages>
</body>
</html>
<?php COUCH::invoke(); ?>


Code: Select all
<?php require_once'../couch/cms.php'; ?>
<!DOCTYPE html>
<html>
<head></head>
<body>
<!--Folders-->
   <cms:folders masterpage='en/gal.php'>
         <cms:show k_folder_title />
   </cms:folders>
<!--Images-->
      <cms:pages masterpage='all/gal.php'>
<img src="<cms:show gg_thumb/>" />
      </cms:pages>
</body>
</html>
<?php COUCH::invoke(); ?>

i tried the last one both with the template tag and without.
The folder in the gallery is called 'cvb'.
File structure:
root/all/gal.php
root/en/gal.php
root/en/gal/cvb
Pages are online at
http://greenvilla.ee/www01/all/gal.php and http://greenvilla.ee/www01/en/gal.php
well this got me confused now...
I was expecting this :)
Don't worry though, I think I can see the problem.

It appears that you are trying to use 'physical' folders ('cvb' e.g.) for the 'en' template to match the virtual folders of the 'all' template.

You actually need to create virtual folders in 'en' exactly the way you did with 'all' - that is by declaring the template as clonable and using 'dynamic_folders'. The modified code for 'en/gal.php' would then become as follows -
Code: Select all
<?php require_once'../couch/cms.php'; ?>
<cms:template title='EN gal' clonable='1' dynamic_folders='1'>

</cms:template>
<!DOCTYPE html>
<html>
<head></head>
<body>
<!--Folders-->
   <cms:folders masterpage='en/gal.php'>
         <cms:show k_folder_title />
   </cms:folders>
<!--Images-->
      <cms:pages masterpage='all/gal.php'>
<img src="<cms:show gg_thumb/>" />
      </cms:pages>
</body>
</html>
<?php COUCH::invoke(); ?>

After visiting the template as super-admin, go into it's folder section in admin-panel and create the same folders as that of 'all/gal.php'. Do make sure to delete the physical 'cvb' folder.

Hope this helps.
oh, so they had to by dynamic.
funny that it seems to have worked with physical folders for a while!
i am sure it did!
maybe i was just seeing what i wanted to see haha...

thanks for all your help!
Would be a great idea to use cms:folder tag instead of dynamic_folders parameter. 1. The synced folders will be protected 2. Easy to copy-paste around 5 templates.
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
8 posts Page 1 of 1