Post by CJC » Thu Oct 15, 2020 12:04 am

Hi All,

On a basic OC 3.0.3.6 installation I'm trying to use the language editor to modify the "Powered By" text in the footer. I have the correct route and key, but any html I put in the Value gets displayed in the front end. This happens even if I just copy/paste the existing string that's in the default. Is there some code I have to insert to designate the html?

Thanks.

CJC
New member

Posts

Joined
Wed Jun 03, 2020 5:51 am

Post by rjcalifornia » Thu Oct 15, 2020 12:16 am

CJC wrote:
Thu Oct 15, 2020 12:04 am
Hi All,

On a basic OC 3.0.3.6 installation I'm trying to use the language editor to modify the "Powered By" text in the footer. I have the correct route and key, but any html I put in the Value gets displayed in the front end. This happens even if I just copy/paste the existing string that's in the default. Is there some code I have to insert to designate the html?

Thanks.
Is the new text not showing up in the footer? Did you disable OpenCart's cache?

Image


Active Member

Posts

Joined
Fri Sep 02, 2011 1:19 pm
Location - Worldwide

Post by CJC » Thu Oct 15, 2020 12:58 am

The new text shows up, but the html code is displayed instead of being interpreted.
rjcalifornia wrote:
Thu Oct 15, 2020 12:16 am

Is the new text not showing up in the footer? Did you disable OpenCart's cache?

CJC
New member

Posts

Joined
Wed Jun 03, 2020 5:51 am

Post by rjcalifornia » Thu Oct 15, 2020 6:12 am

CJC wrote:
Thu Oct 15, 2020 12:58 am
The new text shows up, but the html code is displayed instead of being interpreted.
rjcalifornia wrote:
Thu Oct 15, 2020 12:16 am

Is the new text not showing up in the footer? Did you disable OpenCart's cache?
Can you do a pastebin of the code, and post a screenshot of the footer?

Image


Active Member

Posts

Joined
Fri Sep 02, 2011 1:19 pm
Location - Worldwide

Post by CJC » Thu Oct 15, 2020 7:31 am

Here's a screenshot of the front end: Image
And a screenshot of the language editor screen: Image
And this is the code for the value field:

Code: Select all

Website Design: <a href="http://www.c2-it.com">C2 It Multimedia</a><br /> %s &copy; %s
rjcalifornia wrote:
Thu Oct 15, 2020 6:12 am

Can you do a pastebin of the code, and post a screenshot of the footer?

CJC
New member

Posts

Joined
Wed Jun 03, 2020 5:51 am

Post by by mona » Thu Oct 15, 2020 11:25 am

You can try this
admin/model/design/translation.php
line 4 change

Code: Select all

$this->db->query("INSERT INTO `" . DB_PREFIX . "translation` SET `store_id` = '" . (int)$data['store_id'] . "', `language_id` = '" . (int)$data['language_id'] . "', `route` = '" . $this->db->escape($data['route']) . "', `key` = '" . $this->db->escape($data['key']) . "', `value` = '" . $this->db->escape($data['value']) . "', `date_added` = NOW()");
to

Code: Select all

$this->db->query("INSERT INTO `" . DB_PREFIX . "translation` SET `store_id` = '" . (int)$data['store_id'] . "', `language_id` = '" . (int)$data['language_id'] . "', `route` = '" . $this->db->escape($data['route']) . "', `key` = '" . $this->db->escape($data['key']) . "', `value` = '" . $this->db->escape(html_entity_decode($data['value'], ENT_QUOTES, 'UTF-8')) . "', `date_added` = NOW()");
and line 8 change

Code: Select all

$this->db->query("UPDATE `" . DB_PREFIX . "translation` SET `store_id` = '" . (int)$data['store_id'] . "', `language_id` = '" . (int)$data['language_id'] . "', `route` = '" . $this->db->escape($data['route']) . "', `key` = '" . $this->db->escape($data['key']) . "', `value` = '" . $this->db->escape($data['value']) . "' WHERE `translation_id` = '" . (int)$translation_id . "'");
to

Code: Select all

$this->db->query("UPDATE `" . DB_PREFIX . "translation` SET `store_id` = '" . (int)$data['store_id'] . "', `language_id` = '" . (int)$data['language_id'] . "', `route` = '" . $this->db->escape($data['route']) . "', `key` = '" . $this->db->escape($data['key']) . "', `value` = '" . $this->db->escape(html_entity_decode($data['value'], ENT_QUOTES, 'UTF-8')) . "' WHERE `translation_id` = '" . (int)$translation_id . "'");
Works better on 3.0.3.1 for some reason.

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.


Spinning Social : Links : Menus : Payments : Socials : Ads : Screen Backgrounds : Galleries : Headers : Banners : Promos


Active Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by CJC » Thu Oct 15, 2020 8:45 pm

So I'm assuming based on the need to edit core files to make this work that this should be reported as a bug. Also, another issue is that once you have an edit created, you can never modify it. If you try to open it and make a change when you click the Save button you'll get an error and the screen will have reverted to a blank entry.

CJC
New member

Posts

Joined
Wed Jun 03, 2020 5:51 am

Post by khnaz35 » Thu Oct 15, 2020 8:51 pm

In OC 3.0.3.6 there is well know issue which is related to twig . So no mater how many times you make change unles you fix the twig issue you wont be able to view them.

Urgent Questions shoot here: khnaz35@gmail.com
Enjoy nature ;) :) :-*


User avatar
Active Member

Posts

Joined
Mon Aug 27, 2018 11:30 pm
Location - Malaysia

Post by by mona » Thu Oct 15, 2020 9:36 pm

CJC wrote:
Thu Oct 15, 2020 8:45 pm
So I'm assuming based on the need to edit core files to make this work that this should be reported as a bug. Also, another issue is that once you have an edit created, you can never modify it. If you try to open it and make a change when you click the Save button you'll get an error and the screen will have reverted to a blank entry.
It is indeed and I am sure that Straightlight has seen it :)
I am also aware of that issue with the modify.

It is a new feature for OC3 and has never actually worked properly .. and to be honest it is reasonable to say that since no-one really asks for the fix, no-one really uses it :-X

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.


Spinning Social : Links : Menus : Payments : Socials : Ads : Screen Backgrounds : Galleries : Headers : Banners : Promos


Active Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by by mona » Thu Oct 15, 2020 10:29 pm

For completeness to fix the edit

admin/view/design/translation_form.twig
remove from line 98 - 149

Code: Select all

    {% if key %}
    $('select[name="store_id"]').prop('disabled', true);
    $('select[name="language_id"]').prop('disabled', true);
    $('select[name="route"]').prop('disabled', true);
    $('select[name="key"]').prop('disabled', true);
    $('input[name="key"]').prop('disabled', true);
    {% else %}
    $('select[name="language_id"]').on('change', function() {
      $.ajax({
        url: 'index.php?route=design/translation/path&user_token={{ user_token }}&language_id=' + $('select[name="language_id"]').val(),
        dataType: 'json',
        beforeSend: function() {
          $('select[name="route"]').html('');
          $('select[name="key"]').html('');
          $('input[name="key"]').val('');
          $('textarea[name="default"]').val('');
          $('select[name="store_id"]').prop('disabled', true);
          $('select[name="language_id"]').prop('disabled', true);
          $('select[name="route"]').prop('disabled', true);
          $('select[name="key"]').prop('disabled', true);
          $('input[name="key"]').prop('disabled', true);
          $('textarea[name="value"]').prop('disabled', true);
        },
        complete: function() {
          $('select[name="store_id"]').prop('disabled', false);
          $('select[name="language_id"]').prop('disabled', false);
          $('select[name="route"]').prop('disabled', false);
        },
        success: function(json) {
          html = '<option value=""></option>';

          if (json) {
            for (i = 0; i < json.length; i++) {
              if (i == 0) {
                html += '<option value="' + json[i] + '" selected="selected">' + json[i] + '</option>';
              } else {
                html += '<option value="' + json[i] + '">' + json[i] + '</option>';
              }
            }
          }

          $('select[name="route"]').html(html);

          $('select[name="route"]').trigger('change');
        },
        error: function(xhr, ajaxOptions, thrownError) {
          alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
        }
      });
    });

    var translation = [];
    

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.


Spinning Social : Links : Menus : Payments : Socials : Ads : Screen Backgrounds : Galleries : Headers : Banners : Promos


Active Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by xxvirusxx » Thu Oct 15, 2020 10:50 pm

Same bug is on Master Branch.

OC 2.3.0.2 | OC 3.0.3.6 | Extensions converted by me | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by khnaz35 » Thu Oct 15, 2020 11:40 pm

xxvirusxx wrote:
Thu Oct 15, 2020 10:50 pm
Same bug is on Master Branch.
Btw did you already cover it on your git?

Urgent Questions shoot here: khnaz35@gmail.com
Enjoy nature ;) :) :-*


User avatar
Active Member

Posts

Joined
Mon Aug 27, 2018 11:30 pm
Location - Malaysia

Post by CJC » Fri Oct 16, 2020 2:28 am

This worked. But I had to delete the original entry and re-create it.

Thank You!
by mona wrote:
Thu Oct 15, 2020 11:25 am
You can try this
admin/model/design/translation.php
line 4 change

Code: Select all

$this->db->query("INSERT INTO `" . DB_PREFIX . "translation` SET `store_id` = '" . (int)$data['store_id'] . "', `language_id` = '" . (int)$data['language_id'] . "', `route` = '" . $this->db->escape($data['route']) . "', `key` = '" . $this->db->escape($data['key']) . "', `value` = '" . $this->db->escape($data['value']) . "', `date_added` = NOW()");
to

Code: Select all

$this->db->query("INSERT INTO `" . DB_PREFIX . "translation` SET `store_id` = '" . (int)$data['store_id'] . "', `language_id` = '" . (int)$data['language_id'] . "', `route` = '" . $this->db->escape($data['route']) . "', `key` = '" . $this->db->escape($data['key']) . "', `value` = '" . $this->db->escape(html_entity_decode($data['value'], ENT_QUOTES, 'UTF-8')) . "', `date_added` = NOW()");
and line 8 change

Code: Select all

$this->db->query("UPDATE `" . DB_PREFIX . "translation` SET `store_id` = '" . (int)$data['store_id'] . "', `language_id` = '" . (int)$data['language_id'] . "', `route` = '" . $this->db->escape($data['route']) . "', `key` = '" . $this->db->escape($data['key']) . "', `value` = '" . $this->db->escape($data['value']) . "' WHERE `translation_id` = '" . (int)$translation_id . "'");
to

Code: Select all

$this->db->query("UPDATE `" . DB_PREFIX . "translation` SET `store_id` = '" . (int)$data['store_id'] . "', `language_id` = '" . (int)$data['language_id'] . "', `route` = '" . $this->db->escape($data['route']) . "', `key` = '" . $this->db->escape($data['key']) . "', `value` = '" . $this->db->escape(html_entity_decode($data['value'], ENT_QUOTES, 'UTF-8')) . "' WHERE `translation_id` = '" . (int)$translation_id . "'");
Works better on 3.0.3.1 for some reason.

CJC
New member

Posts

Joined
Wed Jun 03, 2020 5:51 am

Post by CJC » Fri Oct 16, 2020 2:31 am

If anyone is following along, it's: admin/view/template/design/translation_form.twig ;)
by mona wrote:
Thu Oct 15, 2020 10:29 pm
For completeness to fix the edit

admin/view/design/translation_form.twig
remove from line 98 - 149

snip....

CJC
New member

Posts

Joined
Wed Jun 03, 2020 5:51 am

Post by sw!tch » Fri Oct 16, 2020 3:07 am

All this for the {{ powered }} text? A lot less work to just edit your twig template literally one line of code.

Full Stack Web Developer :: Send a PM for Custom Work / Fast Support.
Backup and learn how to recover before you make any changes!


Active Member

Posts

Joined
Sat Apr 28, 2012 2:32 pm
Location - USA

Post by CJC » Fri Oct 16, 2020 3:38 am

But then that gets lost during an update...
sw!tch wrote:
Fri Oct 16, 2020 3:07 am
All this for the {{ powered }} text? A lot less work to just edit your twig template literally one line of code.

CJC
New member

Posts

Joined
Wed Jun 03, 2020 5:51 am

Post by by mona » Fri Oct 16, 2020 3:40 am

CJC wrote:
Fri Oct 16, 2020 3:38 am
But then that gets lost during an update...
YES EXACTLY .. that is why OCMOD and VQMOD are the only protective / logical / sensible / safest ways forward ..

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.


Spinning Social : Links : Menus : Payments : Socials : Ads : Screen Backgrounds : Galleries : Headers : Banners : Promos


Active Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by CJC » Fri Oct 16, 2020 4:32 am

I'm new to OC, but I thought I understood that OCMOD was going away in 3.1. If that's not true are you aware of any guides for using it? I'm willing to learn.
by mona wrote:
Fri Oct 16, 2020 3:40 am
CJC wrote:
Fri Oct 16, 2020 3:38 am
But then that gets lost during an update...
YES EXACTLY .. that is why OCMOD and VQMOD are the only protective / logical / sensible / safest ways forward ..

CJC
New member

Posts

Joined
Wed Jun 03, 2020 5:51 am

Post by by mona » Fri Oct 16, 2020 5:34 am

Yes there is that possibility. There is also the possibility that should this happen VQMOD will return.
Anyway, we are mere mortals .. This example would be this. Then you just add to this single file for all your language files.

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<modification>
	<name>Language Files::by_mona</name>
	<code>Language Files::by_mona</code>
    <version>Language Files V1</version>
    <author>by-mona</author>
    <link>http://support.by-mona.com/ticket/</link>
	
	<file path="catalog/language/en-gb/common/footer.php">
		<operation>
            <search><![CDATA[Powered By <a href="http://www.opencart.com">OpenCart</a><br /> %s &copy; %s]]></search>
			<add position="replace"><![CDATA[Powered By <a href="http://www.c2-it.com.com">C2 It Multimedia</a><br /> %s &copy; %s]]></add>
        </operation>
	</file>

</modification>	
You save this as install.xml
You zip up and call it language files.ocmod.zip (the OCMOD.ZIP is the important bit) upload in install. Modifications (clear &) refresh.

OC3.0.3.6 has a bug in the modification refresh for twig files (this is not a twig its a php, but just FYI). There are a few fixes around, but .. I always tell people to go into the log and press clear first anyway - then top right refresh (the bug is the refresh clear function doesn’t clear twig files) .. clean tidy and gets rid of all the previous refresh data, which you don’t need if you have a quick check through there are no NOT FOUND or ABORTS in the list (which is how you check there are no conflicts / errors ).

I attached a copy so you can just try it.
Here you can read https://github.com/opencart/opencart/wi ... ion-System

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.


Spinning Social : Links : Menus : Payments : Socials : Ads : Screen Backgrounds : Galleries : Headers : Banners : Promos


Active Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by IP_CAM » Fri Oct 16, 2020 6:16 am

are you aware of any guides for using it? I'm willing to learn.
Well, there is a Website, called Google, and they have all infos on such you'll ever need. :laugh:
https://www.google.com/search?q=VqMod+% ... 8&oe=utf-8
But better don't expect anybody to know, what will be next, when it comes to future
OC Versions, most likely 'events', but VqMod will possibly survive even that. :D

And strictly basically, there is no difference between VqMod and OcMod, they both
do the same, namely, 'replacing'/'adding to'/'removing' Code from the OC Source Files.
VqMod 'constructs' a 'cached' Output File out of the 'Result', to then be used, instead of
the original. VqMod places it's 'cached' output FILES into the 'vqmod/vqcache/' Section,
whereby OcMod places it's 'cached' output File CONTENT into the Database.
---
Real Professionals would NOT use both Technologies, it just makes no sense, to do the
same, just in different ways. Why use several 'Engines', if it can be done with one ? ... :crazy: :laugh:
It's contrary to ANY Programmer Logic, anywhere ... :crazy:

So, one should decide on, what to use, and if one decides on VqMod, one should better
completly 'disable' OcMod (in the system/startup.php file, and remove the modification.xml file too),
in order to avoid 'surplus' Server Jobs and timeconsuming Database Access Requirements.
Those Sections would need to be rewritten in the system/startup.php file:
Most likely removed in most parts:

Code: Select all

// Modification Override
function modification($filename) {
	if (defined('DIR_CATALOG')) {
		$file = DIR_MODIFICATION . 'admin/' .  substr($filename, strlen(DIR_APPLICATION));
	} elseif (defined('DIR_OPENCART')) {
		$file = DIR_MODIFICATION . 'install/' .  substr($filename, strlen(DIR_APPLICATION));
	} else {
		$file = DIR_MODIFICATION . 'catalog/' . substr($filename, strlen(DIR_APPLICATION));
	}

	if (substr($filename, 0, strlen(DIR_SYSTEM)) == DIR_SYSTEM) {
		$file = DIR_MODIFICATION . 'system/' . substr($filename, strlen(DIR_SYSTEM));
	}

	if (is_file($file)) {
		return $file;
	}

	return $filename;
}
Most likely removed or edited:

Code: Select all

	if (is_file($file)) {
		include_once(modification($file));

		return true;
	} else {
		return false;
	}
}
Edited:

Code: Select all

// Engine
require_once(modification(DIR_SYSTEM . 'engine/action.php'));
require_once(modification(DIR_SYSTEM . 'engine/controller.php'));
require_once(modification(DIR_SYSTEM . 'engine/event.php'));
require_once(modification(DIR_SYSTEM . 'engine/router.php'));
require_once(modification(DIR_SYSTEM . 'engine/loader.php'));
require_once(modification(DIR_SYSTEM . 'engine/model.php'));
require_once(modification(DIR_SYSTEM . 'engine/registry.php'));
require_once(modification(DIR_SYSTEM . 'engine/proxy.php'));
To this:

Code: Select all

// Engine
require_once(DIR_SYSTEM . 'engine/action.php');
require_once(DIR_SYSTEM . 'engine/controller.php');
require_once(DIR_SYSTEM . 'engine/event.php');
require_once(DIR_SYSTEM . 'engine/router.php');
require_once(DIR_SYSTEM . 'engine/loader.php');
require_once(DIR_SYSTEM . 'engine/model.php');
require_once(DIR_SYSTEM . 'engine/registry.php');
require_once(DIR_SYSTEM . 'engine/proxy.php');
UNTESTED ! (Used last in famous PEKU's OC EDGE 1.5.6.5, many Moons ago ... ::) )
---
OR THEN, use this genious VqMod Engine, it also places and 'handles' it's 'cached'
modified File Content in/from the DB, in/from the same DB (Modification) Section
as used for OcMods. A 'flatfile-type' VqMod Cache Section is so no longer required.
It's one more way, to speed up overall Site Performance, if one likes to use VqMod+OcMod ;)
In addition to avoiding different Cache-Cleaner Tools, to clean up both Cache Sections.
Integrated VQmod for OpenCart
https://www.opencart.com/index.php?rout ... n_id=19501
---
VQMODs to OCMODS or OCMODS to VQMODS
https://www.opencart.com/index.php?rout ... n_id=24897
conversion VQMOD to OCMOD Tool
https://www.opencart.com/index.php?rout ... n_id=28183
---
Just to give you some Idea on this. VqMod has further been used, because OcMod seems not capable, to
do 'everything' what VqMod is capable to, when it comes to some 'specific' Routines, whatever that means.
But I don't know more on this, someone else will possibly be able to ...

Personally, I believe in flat-file VqMod, due to the fact, that my up to ~150 VqMods would use a lot of
additional Space on the Database, and beeing called all the time. And as larger a DB get's, as slower it will be
able, to 'react'. Better use DB's for DATA, (Page-) Code has nothing to do in a Database, it, at best, makes it
more vulnerable. But that's my very personal UnPro Opinion only, so, don't take it for granted. :D

Image

Good Luck! ;)
Ernie

Attachments

vqmod_vqcache.png

vqmod_vqcache.png (118.21 KiB) Viewed 1654 times

Last edited by IP_CAM on Sat Oct 17, 2020 4:43 am, edited 3 times in total.

Please don't send me OC Forum Personal Messages, just contact: jti@jacob.ch
---
OC 1.5.6.5 LIGHT Test Site: http://www.bigmax.ch/shop/
OC 1.5.6.5 V-PRO Test Site: http://www.openshop.li/shop/
My Github OC Site: https://github.com/IP-CAM
2'600+ FREE OC Extensions on the World's largest Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

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

Users browsing this forum: No registered users and 29 guests