Forum

Thread tagged as: Problem, Error

languages regions duplicated

Hi, I've a website in 2 languages and I figured out that randomly are creating new regions duplicated or triplicated (view image). How could I solve this? new regions image Thank you in advance.

Diagnostic Report:

Perch: 2.8.31, PHP: 5.4.45, MySQL: 5.5.51-38.2, with PDO Server OS: Linux, cgi-fcgi Installed apps: content (2.8.31), assets (2.8.31), categories (2.8.31), perch_blog (5.0), perch_events (1.9.3), perch_forms (1.8.3), perch_gallery (2.8.6) App runtimes: <?php $apps_list = array( 'content', 'categories', 'perch_blog', 'perch_events', 'perch_forms', 'perch_gallery', ); PERCH_LOGINPATH: /manejador PERCH_PATH: /home/iclm/public_html/manejador PERCH_CORE: /home/iclm/public_html/manejador/core PERCH_RESFILEPATH: /home/iclm/public_html/manejador/resources Image manipulation: GD Imagick PHP limits: Max upload 64M, Max POST 64M, Memory: 256M, Total max file upload: 64M F1: 2edba60ed1f613d6dd804feb202456a2 Resource folder writeable: Yes DOCUMENT_ROOT: /home/iclm/public_html HTTP_HOST: iclm.cl REQUEST_URI: /manejador/core/settings/diagnostics/ SCRIPT_NAME: /manejador/core/settings/diagnostics/index.php

My Page php

<?php include('../manejador/runtime.php');?>
<?php
    session_start();
    if (isset($_GET['lang']) && $_GET['lang']!='') {
        $lang = $_GET['lang'];
        $_SESSION['lang'] = $lang;
    }elseif (isset($_SESSION['lang'])){
        $lang = $_SESSION['lang'];
    }else{
        // default language
        $lang = 'es';
    }
?>
<!DOCTYPE html>
<html xmlns="https://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title><?php perch_pages_title(); ?></title>
<?php perch_layout('css_tabs'); ?>
</head>
    <body class="wide normal pattern-1 color-6">     
<div id="scroll">
    <div id="contenedor">
            <?php perch_layout('escudo_header'); ?>
            <?php if($lang == 'es'){?>
            <?php perch_layout('menu_2'); ?>
            <?php
            }
            if($lang == 'en'){
            ?>
            <?php perch_layout('menu_2en'); ?>
            <?php
            }
            ?>       
            <?php if($lang == 'es'){?>
            <?php perch_layout('menu_3'); ?>
            <?php
            }
            if($lang == 'en'){
            ?>
            <?php perch_layout('menu_3en'); ?>
            <?php
            }
            ?>         
            <div id="pix"></div>       
            <div id="informacion">
                <div class="container clearfix">
                    <?php perch_content('contenido-'.$lang);?>
                </div>
            </div>
    </div>
</div>
<?php perch_layout('footer_tabs'); ?>
</body></html>
alex s

alex s 0 points

  • 4 years ago
Simon Clay

Simon Clay 127 points

Hi Alex,

Try using the PHP session method in the example page: https://docs.grabaperch.com/perch/building/how-do-i-create-a-multilingual-site/

I think it guards against any old query string being created and triggering new regions.

e.g.:

<?php
    session_start();
    $lang = 'en'; // default lang
    switch(perch_get('lang')) {
        case 'en':
            $lang = 'en';
            break;
        case 'es':
            $lang = 'es';
            break;
        // add more cases for language options here...

        default:
            if (isset($_SESSION['lang'])) {
                $lang = $_SESSION['lang'];
            }
            break;
    }
    $_SESSION['lang'] = $lang;
    ?>
alex s

alex s 0 points

I'll try it! Thanks Simon.