Jump to content
Sign in to follow this  
remix8080

Узнать текущий язык

Recommended Posts

Как можно узнать выбранный язык? Т.е. хочу в зависимости от выбранного языка в header-е показывать разные логотипы.

Спасибо.

Share this post


Link to post
Share on other sites

catalog/controller/common/header.php

<?php
class ControllerCommonHeader extends Controller {
	protected function index() {
		if (($this->request->server['REQUEST_METHOD'] == 'POST') && isset($this->request->post['language_code'])) {
			$this->session->data['language'] = $this->request->post['language_code'];
			
			if (isset($this->request->post['redirect'])) {
				$this->redirect($this->request->post['redirect']);
			} else {
				$this->redirect(HTTP_SERVER . 'index.php?route=common/home');
			}
		}

т.е. язык пишется в сессию.

берите оттуда значение

  • +1 1

Share this post


Link to post
Share on other sites

Спасибо, получилось!

Сделал так:

<?php if ($language_code=="ru") { ?>
      <a href="<?php echo str_replace('&', '&', $home); ?>"><img src="image/data/logo_ru.png" title="<?php echo $store; ?>" alt="<?php echo $store; ?>" /></a>
      <?php } else { ?>
	  <a href="<?php echo str_replace('&', '&', $home); ?>"><img src="image/data/logo_ua.png" title="<?php echo $store; ?>" alt="<?php echo $store; ?>" /></a>
	  <?php } ?>

Share this post


Link to post
Share on other sites

файл/контроллера

if ($this->session->data['language'] == "ru") {
$this->data['logo_image_file'] = "logo_ru.png";
} else {
$this->data['logo_image_file'] = "logo_ua.png";
}

файл/шаблона

<a href="<?php echo str_replace('&', '&', $home); ?>">
<img src="image/data/<?php echo $logo_image_file; ?>" title="<?php echo $store; ?>" alt="<?php echo $store; ?>" />
</a>

имхо компактнее (;

  • +1 2

Share this post


Link to post
Share on other sites

Добрый день. Подскажите, как можно получить id или название текущего языка сайта в header.tpl. Эти данные мне необходимо использовать в js.

Share this post


Link to post
Share on other sites

Вопрос закрыт. Решение:

function getCookie(name) {
  var value = "; " + document.cookie;
  var parts = value.split("; " + name + "=");
  if (parts.length == 2) return parts.pop().split(";").shift();
}

 

Share this post


Link to post
Share on other sites

$this->config->get('config_language_id') в контроллере

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.