Answer the question
In order to leave comments, you need to log in
How to display your multilingual text from the admin panel in the footer of Opencart 3?
Good afternoon, I'm racking my brains on how to display text in the footer from the admin panel:
In the default.php theme controller (in the admin panel), I added the code
if (isset($this->request->post['theme_default_footer_text'])) {
$data['theme_default_footer_text'] = $this->request->post['theme_default_footer_text'];
} elseif (isset($setting_info['theme_default_footer_text'])) {
$data['theme_default_footer_text'] = $setting_info['theme_default_footer_text'];
} else {
$data['theme_default_footer_text'] = false;
}
<div class="form-group">
<label class="col-sm-3 control-label">Текстовый блок</label>
<div class="col-sm-9">
{% for language in languages %}
<div class="input-group"><span class="input-group-addon"><img src="language/{{ language.code }}/{{ language.code }}.png" title="{{ language.name }}" /></span>
<textarea name="theme_default_footer_text[{{ language.language_id }}][text]" rows="5" placeholder="Текстовый блок" class="form-control">{{ theme_default_footer_text[language.language_id] ? theme_default_footer_text[language.language_id].text }}</textarea>
</div>
{% endfor %}
</div>
</div>
$data['text'] = html_entity_decode($this->config->get('theme_default_footer_text' . $this->config->get('config_language_id')), ENT_QUOTES, 'UTF-8');
Answer the question
In order to leave comments, you need to log in
You seem to have covered everything in detail. But!
Forgot to describe how you added {{ text }} to the file "catalog/view/theme/default/template/common/footer.twig" or did you not add it there?
+
If added, did you update the twig cache?
++
Did you var_dump $data['text'] in the controller itself? Something I doubted that something was working out there.
In theory, it should be:
$text = $this->config->get('theme_default_footer_text'); // поле в таблице `oc_setting` называется именно так. А если добавить ID языка, то выйдет 'theme_default_footer_text0'
$data['text'] = $text[$this->config->get('config_language_id')];
Thanks Serge, I changed it to this option and it worked! Thanks again
$data['text'] = $this->config->get('theme_default_footer_text')[$this->config->get('config_language_id')];
It'll do? -
$(document).on('click', '.question > h3', function() {
$(this).next().toggle(200);
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question