Forum for discussing general topics related to Couch.
29 posts Page 2 of 3
Hi all, and KK!

I am trying to implement the above example, but, since I just started with CouchCMS today, I have stumbled across an error. Maybe a quick tip what I did wrong.

So I made a working blog and a list page. Now I would like to make language support with latvian as my primary. This is what I did now:

1. folders "lv" and "en" contain "list.php"
2. lv is the primary, so has this:

Code: Select all
<?php require_once( '../couch/cms.php' ); ?>
<cms:lang_group
    lv='../lv/list.php'
    en='../en/list.php'
   
    _common_fields='datums | lat | lon | my_multiple_images | veids | tips | garums'
/>

<cms:template title='Apraksts' clonable='1' dynamic_folders='1'>

   <cms:editable name='apraksta_teksts' type='richtext' />
   <cms:editable name='mazais' type='text' />

   <!-- shared tags -->

   <cms:editable name='garums' type='text' />
       
        (etc ...)


and then I have my english copy, with the following:

Code: Select all
<?php require_once( '../couch/cms.php' ); ?>
<cms:lang_group
    lv='../lv/list.php'
    en='../en/list.php'

    _common_fields='datums | lat | lon | my_multiple_images | veids | tips | garums'
/>


<cms:template title='Apraksts' clonable='1' dynamic_folders='1'>

   <cms:editable name='apraksta_teksts' type='richtext' />
   <cms:editable name='mazais' type='text' />
   <!-- related EN page -->
    <cms:editable type='relation' name='related_page' label='Related English Page' masterpage='../lv/list.php' has='one' reverse_has='one' />
</cms:template>

<cms:if k_is_page >
<!DOCTYPE html>


But I am getting this error in the english page:

Code: Select all
ERROR: Tag "related_pages": relation field 'related_page' not defined in en/list.php


What did I do incorrectly, or forgot to do?
Hello and welcome, normis :)

The names of templates (as understood by all Couch tags e.g. the 'masterpage' parameter of <cms:pages>) are always relative to the parent folder of 'couch' (this usually is the site's root unless you installed 'couch' within a sub-folder of the main site). For our purpose, we'll call this parent folder the site's root in the discussion that follows.

If a template (lets call it 'list.php') is located directly within the site's root, its name would be 'list.php'. If this template is located within a subfolder 'en' of the root, its name would become 'en/list.php'. If we move it within a subfolder 'test' of 'en', the name would now become 'en/test/list.php'. Couch does not recognize a template that lies outside the root, so we can ignore that scenario.

In case you are unsure about the name of any template, hover your mouse on the template's entry is the admin-panel sidebar and you should see a popup showing its name.

So, in your case, the names of the two templates should simply be 'en/list.php' and 'lv/list.php'.

Please use those names everywhere in your code where you have used '../lv/list.php' and '../en/list.php'.

Also, I'd advice you to please remove the cms:lang_group tags from both templates temporarily. Change the template name in <cms:editable type='relation'> tag, visit the template as super-admin for the change to take effect. Once you can see in the admin-panel that the relation field is visible properly, it is now that you can put back the cms:lang_group tags and continue.

Hope this helps.
Thank you! In the end, I decided to simply use two edit fields, one for each language, and then display the needed language based on the language set in PHP session, in this case, I only have one set of articles and much easier control. Most of the edit fields are universal anyway in my case.
Hi KK, hi forum..

when trying out the new solution for related pages I get an error saying
Code: Select all
"ERROR! ATTRIB_NAME: Invalid char "Â" (line: 2 char: 17)" 

which I do not see.
I have 3 pages in three languages, that I declared within cms:lang_group tag, and I have same declaration for editable region of the type 'relation' in two templates that are not the "master" language...
If anyone can see what is wrong there?
Thanks in advance!
Tanja

de/decloned.php
Code: Select all
<?php require_once( '../couch/cms.php' ); ?>
<cms:lang_group
    de='de/decloned.php'
    en='en/encloned.php'
    sh='sh/shcloned.php'
/>
<cms:template title='de cloned'  order='1' clonable='1' >
<cms:editable name='mycontent' type='richtext' title='Text'  desc='Enter  here'/>
</cms:template>

<cms:if k_is_page>
    <html>
..........
<a href="<cms:show my_link_de />">de</a>
<a href="<cms:show my_link_en />">en</a>
<a href="<cms:show my_link_sh />">sh</a>
.........   
     </html>
<cms:else/>
<cms:embed 'declone.html' />
</cms:if>
<?php COUCH::invoke(); ?>


en/encloned.php
Code: Select all
<?php require_once( '../couch/cms.php' ); ?>

<cms:lang_group
    de='de/decloned.php'
    en='en/encloned.php'
    sh='sh/shcloned.php'
/>
<cms:template title='en cloned'  order='2' clonable='1' >
<cms:editable name='mycontent' type='richtext' title='Text'  desc='Enter  here'/>
   <!-- related DE page -->
     <cms:editable type='relation' name='related_page' label='Related German Page' masterpage='de/decloned.php' has='one' reverse_has='one' />
</cms:template>

<cms:if k_is_page>
    <html>
          ...
<a href="<cms:show my_link_de />">de</a>
<a href="<cms:show my_link_en />">en</a>
<a href="<cms:show my_link_sh />">sh</a>
          ...
</html>
<cms:else/>
<cms:embed 'enclone.html' />
</cms:if>
<?php COUCH::invoke(); ?>


sh/shcloned.php
Code: Select all
<?php require_once( '../couch/cms.php' ); ?>
<cms:lang_group
    de='de/decloned.php'
    en='en/encloned.php'
    sh='sh/shcloned.php'
/>
<cms:template title='sh cloned'  order='3' clonable='1' >
<cms:editable name='mycontent' type='richtext' title='Text'  desc='Enter  here'/>
   <!-- related DE page -->
     <cms:editable type='relation' name='related_page' label='Related German Page' masterpage='de/decloned.php' has='one' reverse_has='one' />
</cms:template>
<cms:if k_is_page>
    <html>
      ...
<a href="<cms:show my_link_de />">de</a>
<a href="<cms:show my_link_en />">en</a>
<a href="<cms:show my_link_sh />">sh</a>
        ...
</html>
<cms:else/>
<cms:embed 'shclone.html' />
</cms:if>
<?php COUCH::invoke(); ?>
Hi Tanja,

Can't see any problem in the code you posted. Perhaps the problem lies somewhere in the embedded snippets?

Please feel free to PM me the access creds to your site (if it is online). I'm sure it won't be a difficult thing to spot.
It's just great! :D
Hi,

I've been testing this solution for multi language sites to see how easy it is to implement and it's really straightforward so far. The only issue I've found is that, for the 'related_page' field on the other languages, the select area displays 'Default page for en/home.php * PLEASE CHANGE THIS TITLE *'.

I notice that in the example, the templates are specified as clonable whereas i'm using this on non clonable templates so I'm assuming this might be the reason. Is it possible to display the correct template title when used on a non clonable template?

Other than that, everything works as expected!

Thanks
Daz
... on from the previous post, I have noticed that the code to switch between languages, e.g.

Code: Select all
<a href="<cms:show my_link_en />">EN</a></cms:if> |
<a href="<cms:show my_link_fr />">FR</a></cms:if>


only shows the correct links when I'm logged into the CMS. Do you have any idea why that would be?

thanks
Daz
Daz, please check if caching is on (in config). Perhaps your anonymous visitors are being served cached contents.

If that is not the case, please double check your code and make sure that you have not mistakenly included some code within the <cms:template> block (this block executes only for super-admins).
Thanks KK, I had put the lang group inside the template tag, my bad!

Can you let me know on the post previous to that?

I've been testing this solution for multi language sites to see how easy it is to implement and it's really straightforward so far. The only issue I've found is that, for the 'related_page' field on the other languages, the select area displays 'Default page for en/home.php * PLEASE CHANGE THIS TITLE *'.

I notice that in the example, the templates are specified as clonable whereas i'm using this on non clonable templates so I'm assuming this might be the reason. Is it possible to display the correct template title when used on a non clonable template?


thanks Daz
29 posts Page 2 of 3