Post by straightlight » Tue Dec 22, 2020 2:15 am

madimar wrote:
Tue Dec 22, 2020 2:04 am
straightlight wrote:
Mon Dec 21, 2020 8:40 am
Directly into the install.xml file to search for lines and alter them.
DO YOU MEAN OCMOD ?!?
Yes and please don't use caps when posting.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

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

Post by madimar » Tue Dec 22, 2020 7:59 pm

straightlight wrote:
Tue Dec 22, 2020 2:15 am
madimar wrote:
Tue Dec 22, 2020 2:04 am
straightlight wrote:
Mon Dec 21, 2020 8:40 am
Directly into the install.xml file to search for lines and alter them.
DO YOU MEAN OCMOD ?!?
Yes and please don't use caps when posting.
Well, thanks for your confirmation. Regarding the caps it was just a few words and in this specific case they were used intentionally to shout my wonder!
So besides that, the point is, removing any ocmod/vqmod support in next releases, it will be necessary and accepted to have some extra queries in order to work with events. It can be ok, just to know.
Said that, in general, about extending Opencart by events, I still think it will be quite a mess to troubleshoot any possible problem/conflict, due to code fragmentation in several files. Is my concern correct according to your opinion?

Regards and thanks for your participation to this topic.

M

-----------------------------------------------------------------------
My last mods: Partita IVA e CF | Pro EU VAT Number | Sales Agents | Pricelist Pro
-----------------------------------------------------------------------


User avatar
Active Member

Posts

Joined
Thu Sep 24, 2009 6:27 pm


Post by OSWorX » Tue Dec 22, 2020 8:45 pm

Just a short clarification.

1. https://github.com/opencart/opencart/wi ... ion-System
Read there:
As of OpenCart 3.1.0.0+ OCMOD will be removed from the OpenCart source code. Only the event system will be used for modifications.
2. Ongoing discussion (closed by Daniel)
https://github.com/opencart/opencart/issues/8992

3. Based on 1. & 2.
OC 3.1.1.0 will be OC 4.x (nearly, OC 4.x replace 3.1.x)
From OC 4.x on, wether OC- nor VQMods are possible anymore, Events shall be handle everything in future.
The file modification.php is removed, which means: no replacements as we know them from OC- or VQMods are possible.

Looking at all of that, it makes me wonder why a replacement via the install.xml (which still exists and is used further) is recommended, because it won't work anymore.
While I am sure that some "clever codie boy" will introduce something and create a "modification" as already exists to eleminate the directory limit introduced with OC 3.x

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


User avatar
Guru Member

Posts

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

Post by JNeuhoff » Tue Dec 22, 2020 9:01 pm

Looking at all of that, it makes me wonder why a replacement via the install.xml (which still exists and is used further) is recommended, because it won't work anymore.
I think all the install.xml will do is to describe the extension, e.g. name, version, author, and link. No more core file modifications.

Override Engine * Integrated VQMod * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Rich Snippets * Google Tag Manager * Export/Import Tool * SpamBot Buster * Survey Plus


User avatar
Expert Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by straightlight » Tue Dec 22, 2020 9:05 pm

Well, thanks for your confirmation. Regarding the caps it was just a few words and in this specific case they were used intentionally to shout my wonder!
Which is why you were being asked why not to use the caps still.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

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

Post by OSWorX » Tue Dec 22, 2020 10:53 pm

JNeuhoff wrote:
Tue Dec 22, 2020 9:01 pm
I think all the install.xml will do is to describe the extension, e.g. name, version, author, and link. No more core file modifications.
Correct, see: https://github.com/opencart/opencart/bl ... r.php#L217

Those infos are needed and stored:

Code: Select all

'extension_id'          => 0,
'extension_download_id' => 0,
'name'                  => $name,
'code'              	=> basename($filename, '.ocmod.zip'),
'version'               => $version,
'author'                => $author,
'link'                  => $link
While the first 2 are internal, the other have to be defined inside the install.xml
Unfortunetaly no version check is made.

Beside the already known install.xml, there is the folder upload [optional] which can contain several subfolders like system, admin, etc.
See: https://github.com/opencart/opencart/bl ... r.php#L289

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


User avatar
Guru Member

Posts

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

Post by kestas » Sat Jan 30, 2021 9:35 pm

madimar wrote:
Tue Dec 22, 2020 2:04 am
straightlight wrote:
Mon Dec 21, 2020 8:40 am
Directly into the install.xml file to search for lines and alter them.
DO YOU MEAN OCMOD ?!?
I do not understand something... @Straightlight always talking to use events everywhere and what is it? OCMOD again? And OCMOD has been removed from OC4.x.x.x... Can anybody explain. I'm confused :crazy:

Custom OpenCart modules and solutions. You can write PM with additional questions... Extensions you can find here


Active Member

Posts

Joined
Tue Oct 12, 2010 2:23 am

Post by OSWorX » Sun Jan 31, 2021 1:45 am

kestas wrote:
Sat Jan 30, 2021 9:35 pm
.. OCMOD has been removed from OC4.x.x.x...
Can anybody explain.
OCMod (therefore also the function modification(..) as sometimes used since OC 2.x) is OBSOLETE!
Removed, niente, nothing, nichts, rien ne va plus ..

From the new Version on - 4.x (3.1.x was planned, but too many changes, therefore 4.0.x) - only events are allowed and possible.
Daniel has screwed that up to replace to old "modification" system with OCMod (and VQMod should be also not be allowed anymore).

But what is true is, that to upload new Extensions, you will use furthermore the well know package.
Including:

a. install.xml
b. upload folder

Infos inside the .xml are used only to store the infos (see the header inside) in the database (currently install.xml is not needed, only the upload folder - maybe Daniel will change that).
The tags as we know, file, path, etc. are not used anymore.

Extension package files will have the same convention as now:
my-extension-v.1.0.0-OC-4.0.1.ocmod.zip

Unfortunetaly I suggested to use another extension (not ocmod furthermore), but Daniel declined.

That's all.

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


User avatar
Guru Member

Posts

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

Post by straightlight » Sun Jan 31, 2021 3:29 am

I do not understand something... @Straightlight always talking to use events everywhere and what is it? OCMOD again? And OCMOD has been removed from OC4.x.x.x... Can anybody explain. I'm confused
Simple. That's because an Event is not OCMod whereas Events is rather an Engine handled by the core.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

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

Post by OSWorX » Sun Jan 31, 2021 5:09 pm

kestas wrote:
Sat Jan 30, 2021 9:35 pm
madimar wrote:
Tue Dec 22, 2020 2:04 am
straightlight wrote:
Mon Dec 21, 2020 8:40 am
Directly into the install.xml file to search for lines and alter them.
DO YOU MEAN OCMOD ?!?
I do not understand something... @Straightlight always talking to use events everywhere and what is it? OCMOD again? And OCMOD has been removed from OC4.x.x.x... Can anybody explain. I'm confused :crazy:
One more: while you are a "developer", all Informations about what is an "Event" and why it is not a "OCMod" and why Events are used in future only and not OCMods (or other derivats), can be read in many postings here in this Forum and in the current code at GitHub - read there also the pull requests and discussions.

As already written, it will confuse many people in future, because the extension package names are only accepted by the system (to install), when they are named xyz.ocmod.zip
From OpenCart 4.0.x on, the already known OCMod is dead.

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


User avatar
Guru Member

Posts

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

Post by Exel » Sat Feb 13, 2021 5:30 pm

I've been looking into code injection into the template files and came across this thread. Lots of good ideas and talk here.

I came up with a simpler solution (I think) than what's been posted here. It works in the same principal as some of the other posts online but it has the nice added bonus that the only thing you need to worry about is finding the html line of what you want to either find / replace ($find var below).

For this we need to create a module / modification .twig file for whatever we are injecting into the target .twig file.

For example, for simplicity sake, if you want to add..

{% if exel %}
<div class="test">{{ exel }}</div>
{% else %}
<div class="test">No</div>
{% endif %}

You would make a .twig file in your module / modification view folder.

I've seen some people do this inline with the template buffer posted in the OP but we can take advantage of the already included $this->load->view().

This way it's a lot cleaner to read and maintain.

We also need to pass whatever variables are needed to this .twig file.

In this instance, I am targeting: admin/view/catalog/product_form/after

My function looks something like this:

Code: Select all

		
public function injectView(&$route, &$data, &$output) {

	$module_twig = $this->load->view('extension/crafted/shipping/craftedanomalies', $data);

	$find = '<legend>Specification</legend>';

	$replace = '<legend>Specification</legend>' . $module_twig;

	$output = str_replace($find, $replace, $output);

}

Where:

$module_twig = This is loading the .twig file / content you want to inject, merging the php / html / twig content and passing the $data to it.

extension/crafted/shipping/craftedanomalies = directory to the .twig file / content you want to inject

$find = The fully converted html string that you want your content to either replace, append to, etc. In my instance, You can see I just appended my .twig to this as it lined up perfectly to where I wanted it.

$replace = This is where you'll either replace or append data.

$output = We are using the /after event $output to push the data.


The nice added bonus of this is you can use the exact same $find for multiple modifications, etc and they will all output from different event calls.

Newbie

Posts

Joined
Sat Feb 13, 2021 5:16 pm
Who is online

Users browsing this forum: No registered users and 2 guests