1 2015-07-27 18:47:22 (edited by HiS 2015-07-27 18:49:13)

Topic: Button Translation

Help to make the button for switch languages, for admin panel.

<?php echo (Form::select('system_language', $languages_array, Option::get('language'), array('class' => 'form-control')));?></div>

example

<?php foreach($opt["access"] as $key => $value):
$active = $item['access'] == $key ? ' class="active"' :  '';
echo '<li'.$active.'><a href="index.php?id=news&action=update_access&uid='.$item['id'].'&access='.$key.'&token='.$token.'">'.$value.'</a></li>';
 endforeach; ?>

2 2015-07-27 18:54:15

Re: Button Translation

Or give a direct link to the switch

example
index.php?id=pages&action=update_status&slug=asadas&status=published&token=72219fc955969f52d014a29d3ef109133205042c

3 2015-07-27 21:37:11 (edited by HiS 2015-07-27 22:46:43)

Re: Button Translation

I do not know how to fix it


install php

bad code

Re: Button Translation

The working code, but it throws to the home page

site.ru/?language=ru -  working
site.ru/admin/?language=ru -  It does not work

<?php
    // Replace last slash in site_url
    $site_url = rtrim($site_url, '/');
    // Languages array
    $languages_array = array('en', 'ru');
    // Select Monstra language
    if (Request::get('language')) {
        if (in_array(Request::get('language'), $languages_array)) {
            if (Option::update('language', Request::get('language'))) {
                Request::redirect($site_url.'admin');
            }
        } else {
            Request::redirect($site_url.'admin');
        }
    }
?>
<div class="install-languages">
<?php foreach ($languages_array as $lang_code) { ?>
<a href="<?php echo '/?language=' . $lang_code; ?>" title="<?php echo I18n::$locales[$lang_code]; ?>" data-placement="top" data-toggle="tooltip" class="language-link echo 'language-link-current';?>">
<img src="<?php echo $site_url; ?>/public/assets/img/flags/<?php echo $lang_code?>.png" alt="<?php echo $lang_code?>">
</a>
<?php } ?>
</div>