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

as KK knows I love couch and I always try this weird and Impossible things so....here is my problem:

I'm doing a website in 2 languages: english and Italian...

so I structured the website with nested pages in the folders root/it and root/en.

Now I have a page root/portfolio.php that is a gallery and I would like a way to fetch the images and folders in the respective part of the template it/portfolio and en/portfolio so the client would just upload the stuff once...:)

But it's not finished....now I visualise the title of each image at the bottom as you can see at root/portfolio

I would like to add two custom field for the images called maybe ita and eng so I could fetch the english field in the english version and the italian in the italian....

Last thing, I have to find a way to switch the website on the same page from one language to the other trough a link at the bottom...

let me know if this is possible

I appreciate as always
Hi Emanuele,

I am sure you had a look at viewtopic.php?f=2&t=74
The 'third' method of building a multi-lingual site details the process of 'switching' languages (this method was added later so in case you missed it please take a look again).

Once you know which language has been selected by the user, it should be easy to display selectively whatever is required for that particular language (it could be images fro gallery or simple text).

Please let me know if something from that post confuses you.

Thanks
Hi KK,

sorry but that post was really confusing. :s

My actual idea was to create 2 hidden template one for the portfolio in italian and one for the one in english that would fetch the gallery.

Is this possible? if yes how do I manage the page that lists the folders?

Another problem is that the gallery photographs are actually pages but their regions can't be edited.

I would just like to add to each image a double description in english and italian so that I could fetch the proper one in each template.

does it make sense?

Last but not least....because my template is not called Index but language/index the masquerade markup doesn't work so the main index.php redirects to the en/index instead of masquerade the content ...will this effect my SEO?

thanks again

thanks
Hi Emanuele,

Could you by any chance grant me access to your site (FTP + Couch)?
I'd like to study the setup firsthand to try and get a better idea as to what your are trying to achieve.

I am sure it is not too complicated for Couch - it is just that I am having trouble getting the whole picture from what you have described (my fault :oops: , not yours).

Thanks
Hi Emanuele,

I had a look at your site and this is how it looks like -
Code: Select all
site_root
  |_couch (folder)
  |_en (folder)
  |   |_index.php
  |_it (folder)
  |   |_index.php
  |_index.php
  |_portfolio.php

This is the first method outlined in viewtopic.php?f=2&t=74 for creating multi-lingual sites (except that you have implemented 'en/index.php' and 'it/index.php' as nested-pages to create rest of the pages of the site).

I see you have used a very interesting method to link all 'en' pages with their 'it' counterparts (and vice-versa) by the use of 'one-to-one relalationship' (http://www.couchcms.com/docs/concepts/r ... ships.html).

The problem that you mentioned is that the 'portfolio.php' template is outside both these folders and hence is language-agnostic.
We need, somehow, to make it know which language has been currently selected and then show the texts in that language (of course images will always be the same).

I think this makes an interesting case where we can actually combine the first method and the third method described in viewtopic.php?f=2&t=74 for multi-lingual sites.

Your main sections are already using the first method. We can now deploy the third method (creating multiple editable regions in the same template) for the portfolio section.
This is how we proceed -

We begin by adding the following lines to en/index.php
<?php require_once( '../couch/cms.php' ); ?>
<?php
if(!session_id()) @session_start();
$_SESSION['lang'] = 'en';
?>

and to it/index.php
<?php require_once( '../couch/cms.php' ); ?>
<?php
if(!session_id()) @session_start();
$_SESSION['lang'] = 'it';
?>

The snippets above saves whatever language the visitor is currently using to browse the main section into session.

Next we modify the 'portfolio.php' template according to the third method -
we add the following at the top of 'portfolio.php' template (immediately below <?php require_once( 'couch/cms.php' ); ?>
Code: Select all
<?php
   if(!session_id()) @session_start();
   global $accepted_langs, $selected_lang;

   // Set your languages here
   $accepted_langs = array( 'en', 'it' );

   if( isset($_SESSION['lang']) && in_array($_SESSION['lang'], $accepted_langs) ){
      $selected_lang = $_SESSION['lang'];
   }
   else{
      $selected_lang = 'en'; // Set your default language here
   }
?>
<cms:set my_lang = "<cms:php>global $selected_lang; echo $selected_lang;</cms:php>" 'global' />

The snippet above tries to find out the currently selected language (by the main section) and sets a variable named 'my_lang'.

At all places in portfolio.php where we require to selectively output something based on the current language, we can use the 'my_lang' variable
for example tis is how we display the menu in the right language-
Code: Select all
<cms:if my_lang='en'>
   <cms:menu masterpage='en/index.php' />   
<cms:else />
   <cms:menu masterpage='it/index.php' /> 
</cms:if>

You can now create editable regions for both languages and display them using the method shown above.

One final piece, uptil now we have been setting the language when the user visits one of the main section. If he happens to land directly on portfolio section, we need to have a way to allow the language section.
We use the same technique described in the original article -
place 'switch.php' in your couch folder and then create the links that invoke it (switch.php simply stores the selected language in session and then redirects to the same page that invoked it).

This is your modified footer with the selector links
Code: Select all
<a href="<cms:show k_admin_link />switch.php?lang=it&redirect=<cms:php>echo urlencode($_SERVER['REQUEST_URI']);</cms:php>">ITALIANO</a> 
-
<a href="<cms:show k_admin_link />switch.php?lang=en&redirect=<cms:php>echo urlencode($_SERVER['REQUEST_URI']);</cms:php>">ENGLISH</a>

Hope this helps
Adding to the last reply -

You are using the description inputted in the 'Edit folder' screen to show text for each folder within portfolio.

For our bi-lingual site we'll require two different inputs (one for each language). As the 'Edit folder' screen allow only one description, we can fall back upon the original technique described in our Aurelius tutorial (http://www.couchcms.com/docs/tutorials/ ... folio.html) - we can use a separate template to store the folder descriptions and create two editable regions within it.
6 posts Page 1 of 1
cron