Problems, need help? Have a tip or advice? Post it here.
5 posts Page 1 of 1
Hello forum!

I make bilingual site with dynamic folders where I have two templates, for each language one, and 3 views within each template - home, folder and page view...
it goes like this

Code: Select all
<html>
<cms:if k_is_page>
           language menu & content
           <cms:else />
                     <cms:if k_is_home>
                      <a href="<cms:show k_site_link />index_en.php" target="_self" class="<cms:if k_template_name=='index_en.php'>selected</cms:if>">en</a>&nbsp;|&nbsp;
    <a href="<cms:show k_site_link />index.php" target="_self" class="<cms:if k_template_name=='index.php'>selected</cms:if>">de</a>
                      & content
                       <cms:else />
                                  <cms:if k_is_folder >   
                                   language menu & content
                                   </cms:if>
                       </cms:if>
</cms:if>
</html>


I have several folders containing pages.... I do not know how to change language when I am in folder view, so that I get the same folder in another language; or when I am in a page view, to get the same page but in another language...

In the moment, I can only call the home view as it should be....

Any suggestions?

Thanks in advance

Tanja
Hi Tanja,

when I am in folder view, so that I get the same folder in another language; or when I am in a page view, to get the same page but in another language
Getting the corresponding other language page/folder presupposes that each page/folder of one language is somehow related to its counterpart page/folder.

For pages, the most straightforward way could be to use 'relations' - We can create a one-to-one relation, say in the DE template, so that while creating a DE page we get a dropdown of EN pages to choose the related page from.

Now on the DE template, we can use cms:related_pages tag to list the (sole) related EN page while on the EN template we can use the cms:reverse_related_pages tag to list the corresponding DE page.

The above solution should be ideal for pages. However, it won't work with folders (as 'relation' only works with pages).

For folders, we can hack our way around by naming the folders in a way that signifies the relation. For example, if there is a folder named 'test' in DE template, we can create a folder named 'en-test' in EN template (i.e. same name with a 'en-' prefixed).

We can now use this naming convention to fetch the related folder from the other template like this -
In DE template (we simply add 'en-' to the current folder name to get the EN folder)
Code: Select all
<cms:if k_is_folder >
    <a href="<cms:link masterpage='index_en.php' folder="en-<cms:show k_folder_name />" />">EN Version</a>
</cms:if>


In EN template (we remove the prefixed 'en-' from folder name to get the DE folder)
Code: Select all
<cms:if k_is_folder >
    <a href="<cms:link masterpage='index.php' folder="<cms:php>echo substr('<cms:show k_folder_name />', 3); </cms:php>" />">DE Version</a>
</cms:if>

Hope this helps.
Do let me know if something is unclear.
Thank you KK!
sorry for late reply, I was not able to work on the website last days...

Everything works great....thanks a lot...

But could you please explain me the following:

At first I had a problem with calling folders, link was not reacting at all and it turned out that I used

Code: Select all
folder='apostroph'
instead of
Code: Select all
 folder="quote sign"


I always thought we should exclusively use apostrophe with Couch and that quotes are reserved for HTML...
Until this case today, everything was working on the sites I used, but in this case the sign seems important....

Tanja

p.s until now, even when I copied the code from documentations I would change the quotes to apostrophes...but the quotes are there for some reason obviously
I am glad it helped, Tanja.

Replying to your question -
Could you please take a look at http://www.couchcms.com/docs/concepts/s ... eters.html ?

I think it should answer your query but just to reiterate -
I've used double-quotes with 'folder' parameter (as in the following example)
Code: Select all
folder="en-<cms:show k_folder_name />"

because the value being fed into it contains nested Couch tags (cms:show in this case) that need to be expanded first.

So, for example, if suppose the 'k_folder_name' variable is 'test', with double-quotes the final value of 'folder' will be en-test.
Had I used single-quotes, the final value would become (literally) en-<cms:show k_folder_name /> as the cms:show tag won't be expanded.

Hope this clarifies the matter.
Thanks again!

Yes that clarifies things!!!!!

I learn new things with every new project...
What I've learned now and what I really love, is that it gives total control over the design, so that the client cannot mess up the look...

Tanja
5 posts Page 1 of 1