Reputation: 87
i want display different message on footer ( /catalog/view/theme/themename/template/common/footer.tpl ) for each respective language of my opencart theme , i tried some code like:
$lang = $this->language->get('code');
echo $lang;
$data['lang'] = $this->language->get('code');
$this->data['language_code'] = $this->session->data['language'];
never of this work;
i want a code like this
if ( $language == 'en' ) { echo 'en'; } elseif ( $language == 'DE' ) { echo 'DE'; } .......
how i can do this with opencart 2.x ?
Upvotes: 0
Views: 1511
Reputation: 134
Define it in the controller first, else the template won't know it exists.
via the Controller; in catalog/controller/common/footer.php: add the following, beneath $data['text_newsletter'] = $this->language->get('text_newsletter');
$data['lang'] = $this->language->get('code');
Now, you can call it in the template: catalog/view/theme/your_theme/common/footer.tpl
<?php echo $lang; ?>
If you want it to behave based on certain criteria:
<?php
if ($lang =='en'){
echo'Your default language is English.';
}elseif($lang =='de'){
echo'Standardsprache ist Deutsch.';
}
?>
Upvotes: 1