Forum for discussing general topics related to Couch.
6 posts Page 1 of 1
FoIks, have a particular problem with displaying correct repeatable value in another language.
Basically, I have two separate languages, each one with different folders for the sake of SEO-friendly URLs.
There are "products" and "applications" sections, where "applications" have a relationship with "products", so we can define appropriate product for each application. For the basic Engilsh "applicaitons" there is no problem, folders and related info from product page are listed correctly:
Code: Select all
<cms:folders masterpage='products/index.php' orderby='title'>
    <cms:related_pages 'related_products' folder="<cms:show k_folder_name/>">
            <h5><cms:show k_page_foldertitle/></h5>
            <cms:show_repeatable 'product_images' limit='1' >
                <img src="<cms:show product_image />" /> <!-- This is the problem with another language display -->
            </cms:show_repeatable>
            <h3><cms:show k_page_title /></h3>
            <p><cms:show product_info_en />
   </cms:related_pages>
</cms:folders>

However, problem arises when trying to list related info into the German language folder. There I have a relationship with English page in order to use product images and other generic stuff already defined instead of filling them again for each language (works fine with product page). However, in German "application" page, product folder header and text info are displayed, but repeatable comes blank. When I insert another <pages> tag just abore my repeatable all values are listed, instead of the correct one. Finally, my question is: Am I able to specify exact value for the repeatable (probably based on page ID etc)? I'm a designer, not a programmer, so please excuse me if something is not clear :)
Please let us know the exact names of all your templates involved in the use-case and also the definitions of all 'relation' regions in each.

Also, the problem code you posted - which template is it in?

Thanks.
Ok, so here we go
My English products page: /products/index.php
Code: Select all
<cms:template title='Products' clonable='1' order='1' dynamic_folders='1'>
<cms:editable name="product_info_en" label="Product Information" type="richtext" toolbar='basic' required='1' order='1' />
<cms:repeatable name='product_images' label="Product Images" order='2' stacked_layout='1'>
    <cms:editable type='image' name='product_image' label='Product Image' show_preview='1' preview_width='100' input_width='700' />
</cms:repeatable>
<cms:repeatable name='product_specs_en' label="Technical specs" order='3'>
     <cms:editable type='text' name='product_spec' label='Spec' />
     <cms:editable type='text' name='product_spec_min' label='Min' />
     <cms:editable type='text' name='product_spec_max' label='Max' />
</cms:repeatable>
... some other fields which are common in all languages
</cms:template>

My English applications page: /applications/index.php
Code: Select all
<cms:template title='Applications' clonable='1' order='2' dynamic_folders='1'>
    <cms:editable type="image" name="sector_page_bg" label="Page bg image" show_preview='1' preview_width='100' required='1' order='1' />
    <cms:editable type="textarea" name="sector_short_info_en" label="Page short info" required='1' order='2' height='100' />
    <cms:editable type="image" name="sector_page_img" label="Page image" show_preview='1' preview_width='100' required='1' order='3' />
    <cms:editable type="richtext" name="sector_txt_en" label="Application text" required='1' order='4' />
    <cms:editable type='relation' name='related_products' label="Related products" masterpage='products/index.php' order_dir='asc' order='5' />
</cms:template>


Then, in the German folder I have again product and application page.
Product page: /de/produkte/index.php (displays fine, values from english page come correct)
Code: Select all
<cms:template title='Produkte' parent='products' clonable='1' order='3' dynamic_folders='1'>
    <cms:editable name="product_info_de" label="Product Information (DE)" type="richtext" toolbar='basic' required='1' order='1' />
    <cms:repeatable name='product_specs_de' label="Technical Specs (DE)" order='3'>
        <cms:editable type='text' name='product_spec' label='Spec' />
        <cms:editable type='text' name='product_spec_min' label='Min' />
        <cms:editable type='text' name='product_spec_max' label='Max' />
    </cms:repeatable>
    <cms:editable type='relation' name='related_page' label='Related English Page' masterpage='products/index.php' has='one' reverse_has='one' />
</cms:template>

German application page: /de/anwendungen/index.php
Code: Select all
<cms:template title='Anwendungen' clonable='1' order='4' dynamic_folders='1'>
    <cms:editable type="image" name="sector_page_bg" label="Page bg image" show_preview='1' preview_width='100' required='1' order='1' />
    <cms:editable type="textarea" name="sector_short_info_de" label="Page short info (DE)" required='1' order='2' height='100' />
    <cms:editable type="image" name="sector_page_img" label="Page image" show_preview='1' preview_width='100' required='1' order='3' />
    <cms:editable type="richtext" name="sector_txt_de" label="Application text (DE)" required='1' order='4' />
    <cms:editable type='relation' name='related_products' label="Related products" masterpage='de/produkte/index.php' order_dir='asc' order='5' />
</cms:template>


So this code in my English "Applications" works fine, related products are listed by folder names, then product name and images are correct. Before the code I'm displaying information, short text, image for each application, which is also fine.
Code: Select all
... other page stuff, no problem here
<cms:folders masterpage='products/index.php' orderby='title'>
    <cms:related_pages 'related_products' folder="<cms:show k_folder_name/>">
            <h5><cms:show k_page_foldertitle/></h5> <!-- Looks fine -->
            <cms:show_repeatable 'product_images' limit='1' >
                <img src="<cms:show product_image />" /> <!-- Looks fine in English -->
            </cms:show_repeatable>
            <h3><cms:show k_page_title /></h3> <!-- Looks fine -->
            <p><cms:show product_info_en /> <!-- Looks fine -->
   </cms:related_pages>
</cms:folders>

Problem arises with German "applications" page (/de/anwendungen/index.php) where product images defined into repeatable do not appear:
Code: Select all
... other page stuff, no problem here
<cms:folders masterpage='de/produkte/index.php' orderby='title'>
    <cms:related_pages 'related_products' folder="<cms:show k_folder_name/>">
            <h5><cms:show k_page_foldertitle/></h5> <!-- Looks fine -->
            <cms:show_repeatable 'product_images' limit='1' >
                <img src="<cms:show product_image />" /> <!-- Does not display in German -->
            </cms:show_repeatable>
            <h3><cms:show k_page_title /></h3> <!-- Looks fine -->
            <p><cms:show product_info_de /> <!-- Looks fine -->
   </cms:related_pages>
</cms:folders>

Thanks, hope that it's more clear now...
Going by the definitions you posted, the following <cms:related_pages> block (placed in '/de/anwendungen/index.php') would fetch pages from 'de/produkte/index.php' -
Code: Select all
<cms:related_pages 'related_products'>

    <!-- What gets fetched here is a page from 'de/produkte/index.php' -->
   
    <!-- 'de/produkte/index.php' does not have any region define 'product_images' in it -->
    <cms:show_repeatable 'product_images' limit='1' > <!-- so this will fail -->
        <img src="<cms:show product_image />" />
    </cms:show_repeatable>

</cms:related_pages>

Now, 'de/produkte/index.php' does *not* contain a repeatable region named 'product_images' so the images don't show up.
That repeatable region is actually defined in '/products/index.php' so to show it you'll need to fetch in the correct page from that template.

In the code above, the page fetched from 'de/produkte/index.php' is in turn related to '/products/index.php' via a type 'relation named 'related_page'.
So you should try doing something like this -
Code: Select all
<cms:related_pages 'related_products'>

    <!-- What gets fetched here is a page from 'de/produkte/index.php' -->
    <!-- We'll fetch the '/products/index.php' page related to it -->
    <cms:related_pages 'related_page'>
   
        <!-- and then access the repeatable-region -->
        <cms:show_repeatable 'product_images' limit='1' >
            <img src="<cms:show product_image />" />
        </cms:show_repeatable>
   
    </cms:related_pages>

</cms:related_pages>

Please try and let me know if this works.
Dear KK, sometimes the obvious thing just escapes because it is so simple! I was trying to get in vain the thing done by get_custom_field and then filtering page ID etc, but of course your suggestion works like a charm :) Thank you very much, best regards
You are welcome :)
I am glad it helped.
6 posts Page 1 of 1