v3.0.3.9 php 8.1
I'm here for a reason, if your response is contact a/the developer, just don't reply.
Code: Select all
$this->load->language('common/header');
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
How would that avoid conflicting variables?straightlight wrote: ↑Tue May 10, 2022 5:43 pmBetter to use a language Event Trigger, /before, as an extension than to call the $this->load->language in order to avoid variable override.
UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk
By the source of the extension, without conflicting with another one. The only downside is the language definition from the core an extension could still override obviously as opposed to the use of the extension switch case with the $this->load->language.paulfeakins wrote: ↑Tue May 10, 2022 6:53 pmHow would that avoid conflicting variables?straightlight wrote: ↑Tue May 10, 2022 5:43 pmBetter to use a language Event Trigger, /before, as an extension than to call the $this->load->language in order to avoid variable override.
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
straightlight wrote: ↑Tue May 10, 2022 7:02 pmBy the source of the extension, without conflicting with another one.paulfeakins wrote: ↑Tue May 10, 2022 6:53 pmHow would that avoid conflicting variables?straightlight wrote: ↑Tue May 10, 2022 5:43 pmBetter to use a language Event Trigger, /before, as an extension than to call the $this->load->language in order to avoid variable override.
UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk
For example in the text editor i put:
"Blah blah blah {{string}} blah blah blah."
{{string}} would contain the text I'm accessing from the language file that is already loaded that I already edited.
For instance, I have a free shipping dollar amount that I need displayed in different areas (blocks, banners, slider, shipping info page, etc.), that dollar amount may change and I just want to edit it in one place like the language file.
v3.0.3.9 php 8.1
I'm here for a reason, if your response is contact a/the developer, just don't reply.
Code: Select all
$_['text_model'] = 'Product Code';
$_['text_reward'] = 'Reward Points:';
after you have retrieved your html from the database you would then replace those placeholders with the value from your language files.
Code: Select all
// example html with placeholders you would normally get from your database
$your_html_with_placeholders = '<span>{{ text_model }} some other text you want {{ text_reward }} and some more text.</span>';
if (preg_match_all('/{{(.*?)}}/', $your_html_with_placeholders, $matches)) {
foreach ($matches[1] as $match) {
// get the replacement text from the language file for the match
$replacement = $this->language->get($match);
// replace it
$your_html_with_placeholders = str_replace('{{'.$match.'}}',$replacement,$your_html_with_placeholders);
}
}
// print the html with replacements
error_log($your_html_with_placeholders);
DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.
https://www.youtube.com/watch?v=zXIxDoCRc84
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
v3.0.3.9 php 8.1
I'm here for a reason, if your response is contact a/the developer, just don't reply.
Then it has additional language files per controller/view which are loaded in the various controllers when needed.
So put your definitions in the main file if you need them in many locations, the replacement code you still have to do in those locations though.
DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.
https://www.youtube.com/watch?v=zXIxDoCRc84
Users browsing this forum: No registered users and 409 guests