Now, I try to add a simple thing to a module in opencart 2.0. The thing I want to archive is:
1. A multilingual input field in the module admin
2. The multilingual text to be displayed in the header in front end.
There is no need to have multiple modules in the admin panel. There will only be one simple text line.
Also, I really want to avoid using the catalog/controller/common/header.php file.
How would this be done the best way, in opencart 1.5 I could use "$this->config->get" to view the message.
This is how its done:
Admin controller file:
Code: Select all
$data['languages'] = $languages;
$this->load->model('localisation/language');
foreach ($languages as $language) {
$custom_text = 'message_' . $language['language_id'];
if (isset($this->request->post[$custom_text])) {
$data[$custom_text] = $this->request->post[$custom_text];
} else {
$data[$custom_text] = $this->config->get($custom_text);
}}
Code: Select all
<?php foreach ($languages as $language) { ?>
<img src="view/image/flags/<?php echo $language['image']; ?>" title="<?php echo $language['name']; ?>" /> Message:
<input name="message_<?php echo $language['language_id']; ?>" value="<?php echo isset(${'message_' . $language['language_id']}) ? ${'message_' . $language['language_id']} : ''; ?>">
<?php } ?>
Code: Select all
<?php echo $this->config->get('message_' . $this->config->get('config_language_id')); ?>
Really thankful if someone would give me some inputs, I guess other amateur developers would like something similar