Post by EagleSK » Fri Jan 16, 2015 7:44 pm

I tried to change a standard footer for all languages.
This part of code causes webserver loop

Code: Select all

	<file path="catalog/language/*/common/footer.php">
		<operation>
			<search><![CDATA[$_['text_powered']]]></search>
			<add position="after"><![CDATA[$_['text_powered']      = '%s &copy; %s';]]></add>
		</operation>
	</file>
When I use index parameter, nothing happens. No modification is generated.

Code: Select all

	<file path="catalog/language/*/common/footer.php">
		<operation>
			<search index="1"><![CDATA[$_['text_powered']]]></search>
			<add position="after"><![CDATA[$_['text_powered']      = '%s &copy; %s';]]></add>
		</operation>
	</file>
Last edited by EagleSK on Wed Apr 08, 2015 3:37 am, edited 1 time in total.

Newbie

Posts

Joined
Fri Jan 16, 2015 7:24 pm

Post by ocextender » Sat Mar 21, 2015 3:49 am

I have noticed a similar issue when I was converting a VQMod into an OCMod. I forgot to change one of the "<search position" tags (more importantly, I didn't create the "<add position" after it) which created an infinite loop in the modification system!

In case any OC developers actually read this, I was using OC 2.0.1.1 and the error is in "admin/controller/extension/modification.php", around line 256 (that is the for loop that becomes an infinite loop I think). There should be a check somewhere just before that loop to ensure that the "add" tag has a "position" attribute - if it doesn't, the modification should be rejected with a clear error.

Looking through the modification system code, there should be a lot more checks on the data, and ideally an awful lot more clarification of errors, e.g. if a mod gets rejected, tell the developer why, and what line the error was on! At the moment it is a lot of stabbing in the dark and hoping for the best :(

I like the idea of the OCMod system, but at the moment it just doesn't seem to be a real competitor for VQMod. Hopefully we will see some [major] improvements in the next OC version.

Newbie

Posts

Joined
Sat Aug 24, 2013 6:38 pm

Post by fido-x » Sat Mar 21, 2015 3:29 pm

For starters, don't use "index" in the search parameter, use "limit". Even then, with the code you're using, you'll potentially end up with something like (using the English language file as an example):

Code: Select all

$_['text_powered']$_['text_powered']      = '%s &copy; %s';      = 'Powered By <a href="http://www.opencart.com">OpenCart</a><br /> %s &copy; %s';
which will obviously cause problems.

But, really, what is it you're trying to achieve? If you want to remove the "Powered by OpenCart" stuff from the language file, the best method is to hard-code it. After all, you're looking at multiple languages, not just a single language.

If you want to use OCMOD, then either:

Code: Select all

<file path="catalog/language/english/common/footer.php">
	<operation>
		<search limit="1"><![CDATA[$_['text_powered']      = 'Powered By <a href="http://www.opencart.com">OpenCart</a><br /> %s &copy; %s';]]></search>
		<add position="replace"><![CDATA[$_['text_powered']      = '%s &copy; %s';]]></add>
	</operation>
</file>
or:

Code: Select all

<file path="catalog/language/english/common/footer.php">
	<operation>
		<search limit="1"><![CDATA[Powered By <a href="http://www.opencart.com">OpenCart</a><br /> ]]></search>
		<add position="replace"><![CDATA[]]></add>
	</operation>
</file>
should provide you with what you seem to want. But, you will need to have a separate <file> section for EACH language file, simply because they are DIFFERENT languages, which means you can't use a wildcard character (*) to make the change in multiple files.

Image
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool

If you're not living on the edge ... you're taking up too much space!


User avatar
Expert Member

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia
Who is online

Users browsing this forum: No registered users and 11 guests