Problems, need help? Have a tip or advice? Post it here.
19 posts Page 2 of 2
Sorry to say, it's me again ... I've downloaded the sample templates and am finding the exact same issue. I can get the clonable news template to work, but the first time visiting news.php generates this error:
Code: Select all
ERROR: Tag "reverse_related_pages": masterpage 'no/nyhet.php' not found

and the first visit to nyhet.php generates this error:
Code: Select all
ERROR: Tag "related_pages": relation field 'related_page' not defined in no/nyhet.php

I then deleted the lang_group tag from both templates, re-registered them and they work OK i.e. I can switch between en/news.php and no/nyhet.php via the links my_link_no and my_link_en - hooray, that's good! BUT ...

I am back to square one with the index.php templates - i.e. the non-clonable templates:

I click view site from the admin panel, am redirected to http://localhost/vertavofestivalen/en/index.php because of the my_lang variable being set in the root level index.php This generates:
Code: Select all
ERROR: Tag "reverse_related_pages": masterpage 'no/index.php' not found

I try to visit http://localhost/vertavofestivalen/no/index.php
Code: Select all
ERROR: Tag "related_pages": relation field 'related_page' not defined in no/index.php

WHen I then delete lang_group tags from both no/index.php and en/index.php, re-register templates, I can visit them OK. I then replace the lang_group tags, re-register the templates and the language links still don't work - there are no my_link_ tags after doing a cms:dump_all

What am I doing wrong or differently to you? I am using Couch V2.0 (20160523) ..... heeeeeeeelp
@potato, I have a feeling you are using an older version of 'multi_lang' addon.
Could you please download it afresh from the original location? -
viewtopic.php?p=18928#p18928

Please let me know if this helps.
done that and unfortunately no change (am sure that's where I downloaded from previously)

Code: Select all
<?php
    if ( !defined('K_COUCH_DIR') ) die(); // cannot be loaded directly

    class KMultiLang{

        function lang_group_handler( $params, $node ){
            global $FUNCS, $PAGE, $CTX;
            if( count($node->children) ) {die("ERROR: Tag \"".$node->name."\" is a self closing tag");}

            // handle params
            $arr_known_params = array( '_related_by'=>'', '_common_fields'=>'' );
            extract( $FUNCS->get_named_vars(
                        $arr_known_params,
                        $params)
                  );
            $_related_by = trim( $_related_by );
            if( $_related_by=='' ){ $_related_by = 'related_page'; } // default name of the relation field connecting pages
            $_common_fields = trim( $_common_fields );

            $templates = array();
            $main_lang = null;
            foreach( $params as $param ){
                $lang = strtolower( trim($param['lhs']) );
                if( array_key_exists($lang, $arr_known_params) ) continue;

                $tpl_name = trim( $param['rhs'] );
                $ext = strtolower( pathinfo($tpl_name, PATHINFO_EXTENSION) );
                if( $ext=='php' ){
                    $templates[$lang] = $tpl_name;
                    if( is_null($main_lang) ){ $main_lang=$lang; } // first template specified is considered the main template
                }
            }

            if( !count($templates) ) return;

            // get down to work ..
            $k_template_name = $CTX->get( 'k_template_name' );
            $code = '';
            if( $CTX->get('k_is_page') || $CTX->get('k_is_list_page') ){

                // if not the main language template, first get the related main language page
                if( $k_template_name != $templates[$main_lang] ){
                    $code .= "<cms:related_pages '".$_related_by."' limit='1' >";
                }

                // get links to pages of other languages through this main language page
                foreach( $templates as $lang=>$tpl ){
                    if( $lang==$main_lang ){
                        $code .= "<cms:set my_link_".$lang."=k_page_link 'global' />";
                    }
                    else{
                        $code .= "<cms:reverse_related_pages '".$_related_by."' masterpage='".$tpl."' limit='1'>
                            <cms:set my_link_".$lang."=k_page_link 'global' />
                        </cms:reverse_related_pages>";
                    }
                }

                // if not the main language template, get resources from the main language page
                if( $k_template_name != $templates[$main_lang] ){
                    if( $_common_fields!='' ){
                        $_common_fields = array_filter( array_map("trim", explode('|', $_common_fields)) );
                        $str_array = $sep = '';
                        foreach( $_common_fields as $field ){
                            $str_array .= $sep . " '" . $field . "'";
                            $sep = ',';
                        }
                        $code .= '
                        <cms:php>
                            global $CTX;

                            $vars = array( '.$str_array.' );
                            $vars = array_filter( array_map(\'trim\', $vars) );

                            foreach( $vars as $var ){
                                $obj = $CTX->get_object_ex( $var, 1 );
                                if( !is_null($obj) ){
                                    $CTX->set_object( $var, $obj, \'global\' );
                                }
                                else{
                                    $CTX->set( $var, $CTX->get($var, 1), \'global\' );
                                }
                            }
                        </cms:php>
                        ';
                    }
                    $code .= "</cms:related_pages>";
                }
            }
            else{
                foreach( $templates as $lang=>$tpl ){
                    $code .= "<cms:set my_link_".$lang."=\"<cms:link '".$tpl."' />\" 'global' />";
                }
            }

            // pass on the generated Couch code to $FUNCS->embed for execution ..
            $html = $FUNCS->embed( $code, $is_code=1 );

            // return output from the code ..
            return $html;
        }
    }

    $FUNCS->register_tag( 'lang_group', array('KMultiLang', 'lang_group_handler') );
@potato, I think you really must move your installation online now for me to do anything useful about this issue.

.
you're right - I'll try to do it ASAP ... thanks!
Hei @KK, @potato,

Were you able to work through a solution for the errors that you were generating on the non-clonable templates?

Because I am facing the same problems with my non-clonable templates.

In other words, the language switcher only works on the clonable templates but fails to switch to the respective language on a non-clonable. I have downloaded the latest multi_lang file and am using COUCH v.2.0 (20160523).

Thanks.
@kajoe14, my reply to you is the same as that to @potato -
can I take a look at the problem myself? I.e., is your site online?

If yes, please PM me the Couch+FTP access creds (with specific instructions on how I can elicit the reported problem).
@kajoe14, thanks for the creds.

I had a look and found two problems -
1. In some templates (e.g. en/index.php and fi/index.php), I could not find the following expected statement -
Code: Select all
<cms:lang_group
    fi='fi/index.php'
    en='en/index.php'
/>

2. In all the templates that you reported as not working, I found that that the 'relation' field did not have the counterpart page selected (you actually need to select the page "Default page ...." and save).

I rectified the problems in two templates - index and pricing and could get both to work as expected.
I think if you do the same for the others, they'll work too.

Hope it helps.
I should have written this weeks ago, but all the same. It worked out perfectly.

Again, thanks @KK
19 posts Page 2 of 2
cron