Forum for discussing general topics related to Couch.
15 posts Page 2 of 2
Here is the code:

en/products.php
Code: Select all
<cms:template title='Products' clonable='1' dynamic_folders='1' gallery='1' folder_masterpage='en/products-folder.php' order='3'>

  <cms:editable
      name="gg_image"
      label="Image"
      desc="Upload your main image here"
      show_preview="1"
      preview_height="200"
      type="image"
   />
   
   <cms:editable
    name        = "gg_thumb"
    assoc_field = "gg_image"
    label       = "CMS Thumbnail Image"
    desc        = "Only used within the admin panel"
    width       = "115"
    height      = "115"
    enforce_max = "1"
    type        = "thumbnail"
   />
   
    <cms:editable
    name        = "grid_thumb"
    assoc_field = "gg_image"
    label       = "Grid Thumbnail Image"
    desc        = "Used on the front end"
    width       = "640"
    height      = "400"
    enforce_max = "1"
    type        = "thumbnail"
/>

<cms:editable name='gallery_css' type='message'>
    <style>
    #k_element_grid_thumb, #k_element_gg_thumb, #k_page_name {
        display: none;
    }
   
    </style>
</cms:editable>

</cms:template>

<!---product menu--->
<!-- if this is NOT a folder -->
                            <cms:if k_is_home>
                                <!-- list folders -->
                                <cms:folders hierarchical='1'>
                                    <!-- and redirect to the first folder that is not top-level -->
                                    <cms:if k_level='1' || k_level='0'>
                                        <cms:redirect url="<cms:show k_folder_link />" />
                                    </cms:if>
                                </cms:folders>
                            </cms:if>
                           
                           
                           
                        <div class="protitle">PRODUCT RANGE</div>
                           <cms:if k_is_page || k_is_folder >
                                <cms:if k_folder_name ><cms:set current_folder=k_folder_name /></cms:if>
                                <cms:if k_page_foldername ><cms:set current_folder=k_page_foldername /></cms:if>
                            </cms:if>
                           
                            <cms:folders hierarchical='1' extended_info='1' include_custom_fields='1'>
                                <cms:if k_level_start >
                                   <cms:set my_class2='' />
                                        <cms:if k_level='0'>
                                            <cms:set my_class2='class="orion-menu red"' />
                                        </cms:if>
                                <UL <cms:show my_class2 />></cms:if>
                                <cms:if k_element_start >
                           
                                    <cms:set my_class='' />
                                    <cms:if "<cms:is_ancestor parent=k_folder_name child=current_folder />" >
                                        <cms:set my_class='class="active"' />
                                    </cms:if>
                           
                                    <LI <cms:show my_class />>
                                    <a href="<cms:if k_folder_immediate_children>javascript:void(0)<cms:else /><cms:show k_folder_link/></cms:if>"><cms:show k_folder_title/></a>
                                </cms:if>
                                <cms:if k_element_end ></LI></cms:if>
                                <cms:if k_level_end ></UL></cms:if>
                            </cms:folders>

<!----display products---->
<cms:if k_is_list >
            <div class="row box">
                <cms:pages folder=k_folder_name include_subfolders='0' limit='12' paginate='1' >
                    <div><a class="fancybox-thumbs fancybox-button" rel="fancybox" href="<cms:show gg_image />" title="<cms:show k_page_title />"><div class="thumbnailwrap sameheight2">
                        <div>
                            <img src="<cms:show grid_thumb />" class="img-responsive" alt="<cms:show k_page_title /> - <cms:show k_folder_title/> ">
                        </div>
                        <span class="rollover" ></span>
                        <span class="text"><cms:show k_page_title /></span>
                    </div></a>
            </div>
           
            <cms:paginator />
            </cms:pages>
      </div>
       
        <cms:else /><!-- k_is_page -->   
            <div class="text-center">
                 <img alt="<cms:show k_page_title /> - <cms:show k_folder_title/> - Timber Art Design Sdn Bhd" src="<cms:show gg_image />"  class="img-responsive" style="max-height:500px; width:auto; margin:0 auto;" />
                 <br>
                    <h1><cms:show k_page_title /> | <a href="<cms:show k_page_folderlink/>">view all <cms:show k_page_foldertitle/> products</a></h1>
                 
            </div>
         
        </cms:if>



en/products-folder.php
Code: Select all
<cms:template title='Product Folder' clonable='1' hidden='1' order='4'>
<cms:editable
      name="chtext"
      label="Chinese Text"
      type="text"
   />

<cms:editable name='gallery_css' type='message'>
    <style>
    #k_element_grid_thumb, #k_element_gg_thumb, #k_page_name {
        display: none;
    }
    </style>
</cms:editable> 
</cms:template>


I have create another "cn" folder which consist exact same files with "en" folder, cn/products.php, cn/products-folder.php.

I know I can do relation between pages, but I got so many products ( > 500), if I do relation, I have to relate >500 pages, one by one. I understand the "relation" this way: I create a product page in english version named "Ac001" which consist products image and product name, then I go to chinese version create a page with same named "Ac001", and make it relate to english version of "Ac001", so it will display same content for both languages.

But both language share the same content, isn't it too stupid to do >500 relations in chinese version? Is there any chance I can just relate the whole folder?

@trendoman, you seems like you are already master this couchcms, maybe you can provide your idea here if you can, I really appreciate and value the help comes from this forum.
I'm trying to grasp your needs, and one idea came to me. Let's find if it helps here.

You will have 3 templates.
1st template (products.php) is in root of website and defines all editables like this:

Code: Select all
<?php require_once( 'couch/cms.php' ); ?>
<cms:template title='Products' ...>

<cms:editable name="gg_image" ...
<cms:editable name="gg_thumb" ...
<cms:editable name="grid_thumb" ...
<cms:editable name='ch_title' type='text' ...


2nd template is put physically in folder /en and its name is en/products.php
It goes like this:

Code: Select all
<?php require_once( '../couch/cms.php' ); ?>
<cms:template title='Products-English' hidden='1'>
<!-- this template has no editables of its own -->
</cms:template>

<cms:pages masterpage='products.php' >

   <cms:show gg_image />
   <cms:show k_page_title />
   
</cms:pages>


3d template is put physically in folder /ch and its name is ch/products.php
It goes like this:

Code: Select all
<?php require_once( '../couch/cms.php' ); ?>
<cms:template title='Products-Chinese' hidden='1'>
<!-- this template has no editables of its own -->
</cms:template>

<cms:pages masterpage='products.php' >

   <cms:show gg_image />
   <cms:show ch_title />
   
</cms:pages>


----------------------------END----------------

This will let you add only 1 picture and put english in the title of page and chinese in special text editable on the same page. You may also want to create editable for english, it is up to you.
Template 2 and 3 will show info from template 1.
It will look like example.com/en/products.php and example.com/ch/products.php

So, now please could you let me know what you think?


PS. No need to manually add information. My latest work required to create csv uploader. With this addon it is possible to autocreate 500 products in 30 seconds. My implementation is maybe not what you need, but i think i can tweak it to help you sort out pictures with folders and post titles and other information, if it can be put all together in csv file (like a text file). This will be handy. In my project i first bulk-upload pictures and then run script to put them in folders according to the list in csv. I also put relations there and populate prices, names, descriptions, colors. No problem adapting to your needs if you have similar task.
Dear @trendoman,

I am just so excited to shared this with you! I think I managed to make relation between folders, I might not do it in correct logic or consist syntax error, but the final result work just fine. I happy if you could point out if I do anything wrong, you can refer this link: http://zcodedesign.com/timber5. As you can see in products' page, it all separate in 2 language link, cn and en. SEO problem SOLVED!

Here is the code, en/products.php:
Code: Select all
<!---product menu --->
<!-- if this is NOT a folder -->
                            <cms:if k_is_home>
                                <!-- list folders -->
                                <cms:folders hierarchical='1'>
                                    <!-- and redirect to the first folder that is not top-level -->
                                    <cms:if k_level='1'>
                                        <cms:redirect url="<cms:show k_folder_link />" />
                                    </cms:if>
                                </cms:folders>
                            </cms:if>
                           
                           
                           
                        <div class="protitle">PRODUCT RANGE</div>
                           <cms:if k_is_page || k_is_folder >
                                <cms:if k_folder_name ><cms:set current_folder=k_folder_name /></cms:if>
                                <cms:if k_page_foldername ><cms:set current_folder=k_page_foldername /></cms:if>
                            </cms:if>
                           
                            <cms:folders hierarchical='1' extended_info='1' include_custom_fields='1'>
                                <cms:if k_level_start >
                                   <cms:set my_class2='' />
                                        <cms:if k_level='0'>
                                            <cms:set my_class2='class="orion-menu red"' />
                                        </cms:if>
                                <UL <cms:show my_class2 />></cms:if>
                                <cms:if k_element_start >
                           
                                    <cms:set my_class='' />
                                    <cms:if "<cms:is_ancestor parent=k_folder_name child=current_folder />" >
                                        <cms:set my_class='class="active"' />
                                    </cms:if>
                           
                                    <LI <cms:show my_class />>
                                    <a href="<cms:if k_folder_immediate_children>javascript:void(0)<cms:else /><cms:show k_folder_link/></cms:if>"><cms:show k_folder_title/></a>
                                </cms:if>
                                <cms:if k_element_end ></LI></cms:if>
                                <cms:if k_level_end ></UL></cms:if>
                            </cms:folders>

<!--- display products --->
<cms:if k_is_list >
            <div class="row box">
                <cms:pages folder=k_folder_name include_subfolders='0' limit='12' paginate='1' >
                    <div><a class="fancybox-thumbs fancybox-button" rel="fancybox" href="<cms:show gg_image />" title="<cms:show k_page_title />"><div class="thumbnailwrap sameheight2">
                        <div>
                            <img src="<cms:show grid_thumb />" class="img-responsive" alt="<cms:show k_page_title /> - <cms:show k_folder_title/> ">
                        </div>
                        <span class="rollover" ></span>
                        <span class="text"><cms:show k_page_title /></span>
                    </div></a>
            </div>
                       
            <cms:paginator prev_text='previous' next_text='next' />
           
            </cms:pages>
      </div>
       
        <cms:else /><!-- k_is_page -->   
            <div class="text-center">
                 <img alt="<cms:show k_page_title /> - <cms:show k_folder_title/> - Timber Art Design Sdn Bhd" src="<cms:show gg_image />"  class="img-responsive" style="max-height:500px; width:auto; margin:0 auto;" />
                 <br>
                    <h1><cms:show k_page_title /> | <a href="<cms:show k_page_folderlink/>">view all <cms:show k_page_foldertitle/> products</a></h1>
                 
            </div>
         
        </cms:if>


In en/products-folder.php:
Code: Select all
<?php require_once( '../admin/cms.php' ); ?>

<cms:template title='Product Folder' clonable='1' hidden='1' order='6'>
<cms:editable
      name="chtext"
      label="Chinese Text"
      type="text"
   />

<cms:editable name='gallery_css' type='message'>
    <style>
    #k_element_grid_thumb, #k_element_gg_thumb, #k_page_name {
        display: none;
    }
    </style>
</cms:editable> 
</cms:template>


<?php COUCH::invoke(); ?>



NOW the CHINESE PART, cn/products.php:
Code: Select all
<!--- products menu --->
<!-- if this is NOT a folder -->
                            <cms:if k_is_home>
                                <!-- list folders -->
                                <cms:folders hierarchical='1'>
                                    <!-- and redirect to the first folder that is not top-level -->
                                    <cms:if k_level='1'>
                                        <cms:redirect url="<cms:show k_folder_link />" />
                                    </cms:if>
                                </cms:folders>
                            </cms:if>
                           
                           
                           
                        <div class="protitle">产品范围</div>
                           
                           
                           
                            <cms:if k_is_page || k_is_folder >
                                <cms:if k_folder_name ><cms:set current_folder=k_folder_name /></cms:if>
                                <cms:if k_page_foldername ><cms:set current_folder=k_page_foldername /></cms:if>
                            </cms:if>
                           
                            <cms:folders hierarchical='1' extended_info='1' include_custom_fields='1'>
                                <cms:if k_level_start >
                                   <cms:set my_class2='' />
                                        <cms:if k_level='0'>
                                            <cms:set my_class2='class="orion-menu red"' />
                                        </cms:if>
                                <UL <cms:show my_class2 />></cms:if>
                                <cms:if k_element_start >
                           
                                    <cms:set my_class='' />
                                    <cms:if "<cms:is_ancestor parent=k_folder_name child=current_folder />" >
                                        <cms:set my_class='class="active"' />
                                    </cms:if>
                           
                                    <LI <cms:show my_class />>
                                    <a href="<cms:if k_folder_immediate_children>javascript:void(0)<cms:else /><cms:show k_folder_link/></cms:if>"><cms:show chtext/></a>
                                </cms:if>
                                <cms:if k_element_end ></LI></cms:if>
                                <cms:if k_level_end ></UL></cms:if>
                            </cms:folders>


<!---Display products --->
<cms:if my_related_folder != '-' >
    <cms:pages masterpage='en/products.php' folder=my_related_folder include_subfolders='0' limit='12' paginate='1'>
   
                    <div><a class="fancybox-thumbs fancybox-button" rel="fancybox" href="<cms:show gg_image />" title="<cms:show k_page_title />"><div class="thumbnailwrap sameheight2">
                        <div>
                            <img src="<cms:show grid_thumb />" class="img-responsive" alt="<cms:show k_page_title /> - <cms:show chtext/> ">
                        </div>
                        <span class="rollover" ></span>
                        <span class="text"><cms:show k_page_title /></span>
                    </div></a>
            </div>
                       
            <cms:paginator prev_text='上一页' next_text='下一页' />
           
            </cms:pages>
</cms:if>


In cn/products-folder.php:
Code: Select all
<?php require_once( '../admin/cms.php' ); ?>

<cms:template title='cn/Product Folder' clonable='1' hidden='1' order='9'>
<cms:editable
      name="chtext"
      label="Chinese Text"
      type="text"
   />
   
<cms:editable
    name="my_related_folder"
    label="Related folder"
    opt_values='my_folder_listing.htm'
    dynamic='opt_values'
    type='dropdown'
/>
   
<cms:editable name='gallery_css' type='message'>
    <style>
    #k_element_grid_thumb, #k_element_gg_thumb, #k_page_name {
        display: none;
    }
    </style>
</cms:editable> 
</cms:template>


<?php COUCH::invoke(); ?>


As I mentioned earlier, I am really weak in understand the logic of couchcms, I just try everything I can put in the code. The code might consist error, I happy if anyone can point it out. Other than that, I just wanted to share the code, hope it helps others too.... :D :D :D
@nsy, congratulations!
Such a great feeling, when something finally works :P Do you happen to know chinese, btw?


I also hope you let me use this thread to reiterate this approach for others too. I will deliberately do it at some distance from code, so the general idea of what you have done is seen clearer.

--
One language (english) is main and template consists of gallery definition for upload pictures and title in english. Gallery has some folders.

Second language (chinese) is secondary and template has title in chinese and additional field, dropdown, showing dynamically all names of folders, created in english template.

To add any more languages, it is needed to create a template, put it in a language folder, ie, /es/template.php And also put a dropdown there to be able to select in admin panel the folder from main template, that will be used as folder to show a clonable page in espanol, in this case.
--


While this can be done in a ton of other ways, it works and therefore is fine.
@trendoman,

no problem, use it. I am glad that I can finally contribute something... :D :D :D :D

And Yes, I know chinese, I am a chinese came from Malaysia...
15 posts Page 2 of 2
cron