Hi was looking for a way to echo a specific piece of code based on selected language
i found this question
viewtopic.php?f=21&t=28364
but is not working anymore in opencast 2
in my theme/template/common/header.tpl i found that $lang echo the correct value but it doesn't work in product template
i found this question
viewtopic.php?f=21&t=28364
but is not working anymore in opencast 2
in my theme/template/common/header.tpl i found that $lang echo the correct value but it doesn't work in product template
Following variable will give you code of the selected language.
$this->session->data['language']
But you cannot use it directly in a .tpl file. You need to assign its value first in controller of the tpl file.
You can use below code to assign its value to a variable.
$data['language_code'] = $this->session->data['language'];
$this->session->data['language']
But you cannot use it directly in a .tpl file. You need to assign its value first in controller of the tpl file.
You can use below code to assign its value to a variable.
$data['language_code'] = $this->session->data['language'];
Regards,
Knowband Team
Opencart Plugins: Knowband Store
Email: support@knowband.com
Since you can't use this session function in 2.0 version's tpl files, you must need to edit controller file to assign its value to a variable.
In version less than 2.0, you can use it directly in tpl files.
In version less than 2.0, you can use it directly in tpl files.
Regards,
Knowband Team
Opencart Plugins: Knowband Store
Email: support@knowband.com
The language code should also be stored in a separate cookie, so you should be able to access it in the template file by doing this:
Code: Select all
<?php $language_code = $_COOKIE['language']; ?>
if use cookie,it always shows the same language,even if you have changed your current language
my extension:https://www.opencart.com/index.php?rout ... estshop24h
email :support@bestshop24h.com
site:http://www.bestshop24h.com
1)go to /catalog/controller/product/product.php after
$data['heading_title'] = $product_info['name'];
add
$data['clanguage'] = $this->session->data['language'];
go to /catalog/view/theme/default/template/product/product.tpl
add the following code to where you want it to display.
<?php echo $clanguage; ?>
now,if you select "English" ,it will show "en-gb",if you select "简体中文",it will show "zh-cn".
$data['heading_title'] = $product_info['name'];
add
$data['clanguage'] = $this->session->data['language'];
go to /catalog/view/theme/default/template/product/product.tpl
add the following code to where you want it to display.
<?php echo $clanguage; ?>
now,if you select "English" ,it will show "en-gb",if you select "简体中文",it will show "zh-cn".
my extension:https://www.opencart.com/index.php?rout ... estshop24h
email :support@bestshop24h.com
site:http://www.bestshop24h.com
tingwing wrote: ↑Wed Jul 26, 2017 9:57 am1)go to /catalog/controller/product/product.php after
$data['heading_title'] = $product_info['name'];
add
$data['clanguage'] = $this->session->data['language'];
go to /catalog/view/theme/default/template/product/product.tpl
add the following code to where you want it to display.
<?php echo $clanguage; ?>
now,if you select "English" ,it will show "en-gb",if you select "简体中文",it will show "zh-cn".
Hello, thank you very much for this info, it really worked
Web site: https://www.erkekgiyim.com
Respects
If you need a different page for a different language, why not just use an information page with different translations? It should let you enter content for each language, so you can customize it however you want.
If you don't need an entire page, but just a banner or module with different content, you should be able to use an HTML module for that. It also lets you assign content for each language, so you can display different things conditionally, based on the customer's language choice.
If you need something that doesn't go in a specific module position, but is embedded within some other content, you'll need to use tingwing's edit above. You modify the controller file, and then add the corresponding variable in the template file. If that's too complicated for you, I do have an Infinite Module Positions extension that lets you hook modules onto any HTML element on a page. That should let you put an HTML module anywhere you want. Feel free to take a look at the screenshots and demo site, and if you're interested let me know at www.getclearthinking.com/contact if you have any further questions.
If you don't need an entire page, but just a banner or module with different content, you should be able to use an HTML module for that. It also lets you assign content for each language, so you can display different things conditionally, based on the customer's language choice.
If you need something that doesn't go in a specific module position, but is embedded within some other content, you'll need to use tingwing's edit above. You modify the controller file, and then add the corresponding variable in the template file. If that's too complicated for you, I do have an Infinite Module Positions extension that lets you hook modules onto any HTML element on a page. That should let you put an HTML module anywhere you want. Feel free to take a look at the screenshots and demo site, and if you're interested let me know at www.getclearthinking.com/contact if you have any further questions.
Who is online
Users browsing this forum: No registered users and 180 guests