Post by andyexeter » Tue Jan 28, 2014 11:05 pm

I'm an experienced OpenCart developer but have only just started playing around with writing my own vQmods

I want to hide the meta keywords field from all admin forms. I wrote something up which after reading the scripting guide I now know won't work:

Code: Select all

<file path="admin/view/template/catalog/" name="*_form.tpl">
		<operation>
			<search position="replace" offset="-1" index="1"><![CDATA[<td><?php echo $entry_meta_keyword; ?>]]></search>
			<add><![CDATA[<tr style="display:none;">]]></add>
		</operation>
</file>
Obviously negative offsets don't work, but I just want to replace the <tr> parent of all <td><?php echo $entry_meta_keyword; ?></td> with <tr style="display:none;"> in all form templates

Is there a way of doing this without using jQuery/JavaScript to manipulate the DOM?

I'm using vQMod version 2.4.1 and OpenCart version 1.5.6.1 - Any help would be much appreciated

Thanks, Andy

Newbie

Posts

Joined
Tue Jan 28, 2014 10:54 pm
Location - Exeter, England

Post by webvet » Wed Jan 29, 2014 8:56 am

Andy

Try this out - working on my local server:

Code: Select all

<operation>
		<search position="ibefore"><![CDATA[
		<td><?php echo $entry_meta_keyword; ?></td>
		]]></search>

		<add><![CDATA[
		<tr style="display: none">
		]]></add>
	</operation>
The 'ibefore' attribute inserts the new line of code before the search line INSTEAD of the previous line.

HTH?

Genuine, Honest Opencart Support @ http://webvetservices.com


User avatar
Active Member

Posts

Joined
Thu May 14, 2009 2:04 am
Location - Shropshire, UK

Post by andyexeter » Wed Jan 29, 2014 4:54 pm

Thanks for your reply webvet. The code you provided does work in terms of hiding the meta keywords field but it does not replace the parent <tr> - The vqcache file now looks like:

Code: Select all

<tr>
    <tr style="display:none;"><td><?php echo $entry_meta_keyword; ?></td>
</tr>
This is basically the same as using the 'before' keyword except the new <tr> is displayed on the same line as the <td>

I'd really just like to replace the parent <tr> itself as I'm left with invalid markup now :(

Thanks again for the help

Newbie

Posts

Joined
Tue Jan 28, 2014 10:54 pm
Location - Exeter, England

Post by webvet » Wed Jan 29, 2014 5:37 pm

Sorry - it was too late when I replied... Didn't spot that extra <tr>!!!!

This seems to work for the product form, haven't tested it on any other pages but might be worth a try:

Code: Select all

<operation>
		<search position="replace" offset="3"><![CDATA[
		<td><textarea name="product_description[<?php echo $language['language_id']; ?>][meta_description]" cols="40" rows="5"><?php echo isset($product_description[$language['language_id']]) ? $product_description[$language['language_id']]['meta_description'] : ''; ?></textarea></td>
]]></search>

		<add trim="true"><![CDATA[
		<td><textarea name="product_description[<?php echo $language['language_id']; ?>][meta_description]" cols="40" rows="5"><?php echo isset($product_description[$language['language_id']]) ? $product_description[$language['language_id']]['meta_description'] : ''; ?></textarea></td>
		</tr>
		<tr style="display: none">
		<td><?php echo $entry_meta_keywords; ?></td>
		]]></add>
</operation>

Genuine, Honest Opencart Support @ http://webvetservices.com


User avatar
Active Member

Posts

Joined
Thu May 14, 2009 2:04 am
Location - Shropshire, UK

Post by andyexeter » Wed Jan 29, 2014 5:47 pm

Great idea using the meta_description field and replacing lines below! Works perfectly, thanks very much. I might try playing with a regex pattern to catch all if it doesn't work for other forms

Thanks again webvet I appreciate the help

Newbie

Posts

Joined
Tue Jan 28, 2014 10:54 pm
Location - Exeter, England

Post by andyexeter » Wed Jan 29, 2014 6:55 pm

For anybody that stumbles across this post here is the final working operation using a regular expression to hide the meta_keywords field on all forms:

Code: Select all

	<file path="admin/view/template/catalog/" name="*_form.tpl">
    <operation>
          <search position="replace" offset="3" regex="true"><![CDATA[~(<td><textarea.*name=".*\[meta_description\]".*)~]]></search>
          <add trim="true"><![CDATA[\1
          </tr>
          <tr style="display: none">
          <td></td>
          ]]></add>
    </operation>
	</file>

Newbie

Posts

Joined
Tue Jan 28, 2014 10:54 pm
Location - Exeter, England
Who is online

Users browsing this forum: No registered users and 75 guests