Post by SynysterDory » Thu Jan 30, 2020 2:05 am

Version 3.0.3.2
I want to show the instructions for bank transfer just like this but I don't know how to achieve that
Image

New member

Posts

Joined
Fri Nov 22, 2019 3:52 am
Location - México

Post by IP_CAM » Thu Jan 30, 2020 10:35 am

You might add some content, and also some html code like <br> <p></p> etc. to the
text_description or text_payment line:
OC_3.0.2.0/catalog/language/en-gb/extension/payment/bank_transfer.php

Code: Select all

<?php
// Text
$_['text_title']       = 'Bank Transfer';
$_['text_instruction'] = 'Bank Transfer Instructions';
$_['text_description'] = 'Please transfer the total amount to the following bank account.';
$_['text_payment']     = 'Your order will not ship until we receive payment.';

My Github OC Site: https://github.com/IP-CAM
5'600 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by OSWorX » Thu Jan 30, 2020 8:04 pm

Completely wrong approach or solution!

Since OpenCart 3.x you can edit any language variable with the already integrated Language Editor.
Simply call that via the Menu > Language Editor.

Then hit the PLUS Button right top.
Select then the Store and the Language.
Third select in the field route this here: extension/payment/bank_transfer
Then select text_payment in the field key.
And finally add your own text in the last fields > save.

No matter how you do it (direct edit) or via the Language Editor, the moment you want to use some styling (e.g. HTML-Codes like b, color, etc.), this will work only if you edit the controller file (direct or as OCMod [preferred]):
catalog/controller/extension/payment/bank_transfer.php

There you have to insert inside the function index() after

Code: Select all

$this->load->language('extension/payment/bank_transfer');
this here:

Code: Select all

$data['text_instruction'] = html_entity_decode( $this->language->get( 'text_instruction' ), ENT_QUOTES, 'UTF-8' );
$data['text_payment'] = html_entity_decode( $this->language->get( 'text_payment' ), ENT_QUOTES, 'UTF-8' );
Now your custom text with HTML-Codes are displayed correct.

Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.


User avatar
Administrator

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by thekrotek » Thu Jan 30, 2020 10:37 pm

OSWorX wrote:
Thu Jan 30, 2020 8:04 pm
No matter how you do it (direct edit) or via the Language Editor, the moment you want to use some styling (e.g. HTML-Codes like b, color, etc.), this will work only if you edit the controller file (direct or as OCMod [preferred]):
catalog/controller/extension/payment/bank_transfer.php
You, of course, DO CAN add HTML to language files and you DO NOT need to add anything to controller to make it work.

Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com


User avatar
Expert Member

Posts

Joined
Sun Jul 03, 2016 12:24 am


Post by OSWorX » Fri Jan 31, 2020 4:12 am

thekrotek wrote:
Thu Jan 30, 2020 10:37 pm
OSWorX wrote:
Thu Jan 30, 2020 8:04 pm
No matter how you do it (direct edit) or via the Language Editor, the moment you want to use some styling (e.g. HTML-Codes like b, color, etc.), this will work only if you edit the controller file (direct or as OCMod [preferred]):
catalog/controller/extension/payment/bank_transfer.php
You, of course, DO CAN add HTML to language files and you DO NOT need to add anything to controller to make it work.
Oh yes, YOU can if you want.
But then you will see only something like this:

Code: Select all

This is <b>your</b> <span style="color:green">Payment Instruction</span>
If YOU want that, then leave the controller as it is ..
Guess you haven't try it before posting.

Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.


User avatar
Administrator

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by thekrotek » Fri Jan 31, 2020 4:42 am

OSWorX wrote:
Fri Jan 31, 2020 4:12 am
Guess you haven't try it before posting.
I'm afraid, my friend, this is YOU who haven't tried it before posting, because even default OC language files have HTML in them. For example, footer.php:

Code: Select all

$_['text_powered']  = 'Powered By <a href="http://www.opencart.com">OpenCart</a><br /> %s &copy; %s';
So yes, it is possible to add HTML to language files. I was referring specifically to this part of your reply, where you say something about editing the controller to display HTML.

Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com


User avatar
Expert Member

Posts

Joined
Sun Jul 03, 2016 12:24 am


Post by straightlight » Fri Jan 31, 2020 5:04 am

Guys, GUYS - let's not argue about this. The OP is using OC v3.x releases anyways which means the |format notations can be used in TWIG files which is why most of developers don't understand why language definitions are no longer used in controllers but rather used directly into TWIG files so to avoid parsing language files from PHP to prevent XSS vulnerabilities by people who understands the purpose even less while other platform developers have also considered using the same path as much as Opencart did. We're not the only ones!

To clarify both postings; Using HTML entities in language files are not good practices and editing controller core files by parsing html_entity_decode can still be achieved but requires a controller and language file to be created / edited while TWIG files already captures the language files from the controllers. There are multiple TWIG files from the core where the format notations can be referred from in order to avoid editing controller files or adding HTML codes into language files. Both answers provides different methods but also both ways can still lead to the wrong answers. Let's not forget by using html_entity_decode that .user.ini / php.ini can already handle this without the need to use a PHP function which is why it has been added in the OC package from opencart.com originally in the first place and, on the other way around, using HTML codes in language files are no longer necessary since each can be applied from theme files on anyhow.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by OSWorX » Fri Jan 31, 2020 6:14 am

thekrotek wrote:
Fri Jan 31, 2020 4:42 am
OSWorX wrote:
Fri Jan 31, 2020 4:12 am
Guess you haven't try it before posting.
I'm afraid, my friend, this is YOU who haven't tried it before posting, because even default OC language files have HTML in them. For example, footer.php:

Code: Select all

$_['text_powered']  = 'Powered By <a href="http://www.opencart.com">OpenCart</a><br /> %s &copy; %s';
So yes, it is possible to add HTML to language files. I was referring specifically to this part of your reply, where you say something about editing the controller to display HTML.
Well I had, otherwise I would not post such things!
Here 2 images as it would be displayed (Original OC 3.0.3.2 Installation) without extra modification:
Image
Image

And for @straightlight:
used directly into TWIG files
Is heavy midleading, because since the OC 1.4.x days the language file (translation) is loaded in the controller always by

Code: Select all

$this->load->language('extension/payment/bank_transfer');
The only difference to former (OC > 3.x version) is: now the $data is automatically filled, before it had to be assigned like

Code: Select all

$data = $this->load->language('extension/payment/bank_transfer');
And the $data array is assigned (and used ) by the template files.

And before OC 3.x it was like this (sample bank_transfer):

Code: Select all

$this->load->language('extension/payment/bank_transfer');

$data['text_instruction'] = $this->language->get('text_instruction');
$data['text_description'] = $this->language->get('text_description');
$data['text_payment'] = $this->language->get('text_payment');
$data['text_loading'] = $this->language->get('text_loading');
A stupid and useless assigning of language vars (and wasting space) inside the controllers are gone (a very long discussion since 8 years came to an end!).

And to complete all, the twig syntax "format" is not used in any template (as fas as I know currently).
https://twig.symfony.com/doc/2.x/filters/format.html

And has has no relevance here, because here are no placeholders a sprintf would use.

Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.


User avatar
Administrator

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by straightlight » Fri Jan 31, 2020 6:16 am

Is heavy midleading, because as the OC 1.4.x days the language file (translation) is loaded in the controller always by
What was meant by definition over there is the fact that users can directly call the language tag without the need to play with core controllers as mentioned above as well. Since that part was also mentioned, it is not misleading but rather informative.

As for the rest of your above reply, it simply describes in technical form how the theory has been explained on my previous reply regarding the $data array.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by SynysterDory » Wed Feb 05, 2020 1:04 am

Thats a lot of info I can use, thanks people

New member

Posts

Joined
Fri Nov 22, 2019 3:52 am
Location - México
Who is online

Users browsing this forum: No registered users and 3 guests