Page 1 of 1

VQMod patch failing

Posted: Fri Nov 11, 2011 4:46 am
by desperado
I wrote a standalone php file that I am trying to include somewhere and it doesn't seem to be working.

if I modify the actual file with

Code: Select all

include('addons/test.php');
it works fine.

If I try a VQMod, it fails.

Code: Select all

<modification>
	<id>Test for OpenCart 1.5</id>
	<version>1.1.1</version>
	<vqmver>2.1</vqmver>
	<author>Eric</author>
	<file name="index.php">
		<operation>
		<search position="after"><![CDATA[require_once('config.php');]]></search>
		<add><![CDATA[include('addons/test.php');]]></add>
		</operation>
	</file>
</modification>
Actually, I can't say it fails, because I get no vqmod log error, and no php error. I have tried including it in different files, but I get similar results. could there be issues with caching or otherwise?

Re: VQMod patch failing

Posted: Fri Nov 11, 2011 5:23 am
by wernerrenrew
Hi,

When i first started to use vqmod i took a peek at it's code and i remember that on install it changes the index to it's needs, you can use vqmod for every file loaded after the index.

Regards Werner

Re: VQMod patch failing

Posted: Fri Nov 11, 2011 5:34 am
by Qphoria
Right.. you cannot use vQmod on index.php files as that is the page that loads vQmod... Chicken and Egg

Re: VQMod patch failing

Posted: Fri Nov 11, 2011 6:07 am
by wernerrenrew
Hmmm chicken :D

Re: VQMod patch failing

Posted: Fri Nov 11, 2011 6:15 am
by Xsecrets
It's not really the right place to put it, but when I was looking for somewhere to stick code using vqmod that runs before the controllers do I hijacked the top of the maintenance file because it gets run as a preaction and runs before any controllers get loaded.

Re: VQMod patch failing

Posted: Fri Nov 11, 2011 9:21 am
by Qphoria
Xsecrets wrote:It's not really the right place to put it, but when I was looking for somewhere to stick code using vqmod that runs before the controllers do I hijacked the top of the maintenance file because it gets run as a preaction and runs before any controllers get loaded.
Wasn't startup.php good enough? Or was it too early in the script?

Re: VQMod patch failing

Posted: Fri Nov 11, 2011 9:28 am
by desperado
Thanks gentlemen.

I move it to the header.tpl. It doesn't really need to execute at that high a level. I also noticed a typo once I moved it.

now works as advertised.

Re: VQMod patch failing

Posted: Fri Nov 11, 2011 9:57 am
by Xsecrets
Qphoria wrote:
Xsecrets wrote:It's not really the right place to put it, but when I was looking for somewhere to stick code using vqmod that runs before the controllers do I hijacked the top of the maintenance file because it gets run as a preaction and runs before any controllers get loaded.
Wasn't startup.php good enough? Or was it too early in the script?
well I needed the session library to be loaded already, so startup was too early. I would be nice if the preaction section was somewhere that you could modify with vqmod, because it's the perfect place for lots of things.

Re: VQMod patch failing

Posted: Sat Oct 13, 2012 1:05 am
by 3rdcorner

Code: Select all

	<file name="system/engine/front.php">
		<operation error="log">
			<search position="after"><![CDATA[public function dispatch($action, $error) {]]></search>
			<add><![CDATA[$this->addPreAction(new Action('common/xen_seo_url'));]]></add>
		</operation>
	</file>
O0

Feels hackish, but so is the concept of vqmods anyways. Ideally we should be able to overload controllers and use OOP without modifying core files, but meh.

Edit: VQMods is great, btw.

My recommendation is to create a /modules/ folder where you store packages for OpenCart so they can be easily transferred between projects using the /modules/ folder and a vqmod sparingly to force inclusion of files rather than multiple lines of code inside the .xml files. This is much more maintainable than trying to get syntax highlighting for PHP working inside an XML file, or copying-and-pasting ad infinitum.

Re: VQMod patch failing

Posted: Sat Oct 13, 2012 4:10 am
by Qphoria
3rdcorner wrote:

Code: Select all

	<file name="system/engine/front.php">
		<operation error="log">
			<search position="after"><![CDATA[public function dispatch($action, $error) {]]></search>
			<add><![CDATA[$this->addPreAction(new Action('common/xen_seo_url'));]]></add>
		</operation>
	</file>
O0

Feels hackish, but so is the concept of vqmods anyways. Ideally we should be able to overload controllers and use OOP without modifying core files, but meh.

Edit: VQMods is great, btw.

My recommendation is to create a /modules/ folder where you store packages for OpenCart so they can be easily transferred between projects using the /modules/ folder and a vqmod sparingly to force inclusion of files rather than multiple lines of code inside the .xml files. This is much more maintainable than trying to get syntax highlighting for PHP working inside an XML file, or copying-and-pasting ad infinitum.
You will want to check this out:
http://forum.opencart.com/viewtopic.php?f=24&t=85873