Post by threebuoys » Sun Jul 01, 2012 11:40 pm

Thanks to all who built this utility.

I have successfully written a couple of scripts. I need a clarification on how the replace options.

I have successfully used partial strings in the modification/file/operation/search/position="attribute" parameter to locate the data to be modified.

I have not successfully "replaced" the partial string with a new string or "added" additional data immediately after the partial string. The combinations of attributes I have tried seems to always insert the new string in a new line before or after the entire line in which the partial string was found, not immediately before or after the partial string but within the same line.

The only combination therefore that I've been able to do successfully is to search for an entire line and replace an entire line.

Is this the correct behavior? The instructions implied partial string searches and replaces or incremental adds could be made with VQmod, but I may have misunderstood.

If anyone can enlighten me, thank you in advance. In the meantime, I'll continue using full line searches and replaces.

David

v1.5.2.1; vqmod


Newbie

Posts

Joined
Mon Apr 09, 2012 10:53 am
Location - Avon, NC

Post by Avvici » Thu Jul 05, 2012 2:31 pm

I would recommend looking at the documentation on this which is here:
http://code.google.com/p/vqmod/wiki/Scripting

User avatar
Expert Member

Posts

Joined
Tue Apr 05, 2011 12:09 pm
Location - Asheville, NC

Post by threebuoys » Thu Jul 05, 2012 7:41 pm

Thanks Avvici,

This is the documentation I've been using to learn vQmod and it's been quite helpful.
The part of the documentation I've been using specifically,

"replace will replace the data in the search tag with the data in the add tag. (default)
before will insert the add data before the search data
after will insert the add data after the search data
top will insert the add data at the top of the file. The search data is ignored.
bottom will insert the add data at the bottom of the file. The search data is ignored"

I've tried the replace,before, and after. It seems to always position the add following or preceding the entire line of code in which the partial search data was found, not immediately before or after the search data within the line. Likewise, the replace seems to remove the entire line, not just the search data, and replace it with the new line.

I'm just trying to get someone to confirm that this is the correct behavior or that I'm trying to do something not intended Bvy vQmod. If that's the case, I can make it work with full strings, but if I just haven't done it correctly, then partial replacements would be nice so I'll keep on experimenting until I get it right.

Thanks for your help

David

v1.5.2.1; vqmod


Newbie

Posts

Joined
Mon Apr 09, 2012 10:53 am
Location - Avon, NC

Post by Avvici » Fri Jul 06, 2012 5:04 am

Replace replaces the specified string to be replaced with the added string.
After adds the added string directly after specified string.
Before adds the added string directly before specified string.

Then you can have powerful use of OFFSET and INDEX which if you don't know how to use, you should learn.

User avatar
Expert Member

Posts

Joined
Tue Apr 05, 2011 12:09 pm
Location - Asheville, NC

Post by threebuoys » Fri Jul 20, 2012 9:26 am

Thanks Avvici for your earlier responses. I've not been able to get back to this for the past couple of weeks. I'm still not sure I've adequately explained what I've experienced. I've included code for a simple example below. The test website is http://www.three-buoys.com/cart/

What I hoped to accomplish with this particular mod was to add a facebook like button to either the front or end of the top meu defined in the default OC template by div class="links"

The example below uses the after option to add the code. In the first operation, immediately after the div class="links". In the second operation, immediately after the last item in the class but before the end of the div. (clearly only one would be used, this is just an example) Both operations correctly find the search strings I used. Both operations added the new code after the end of the entire original line of code containing the strings, which, for the default template, was the end of the div class="links"

This has led me to conclude partial strings can be found in the search, but the new code will be added after the entire line of code. So, the vQmods I've written since my original question has searched and replaced entire lines.

My question remains the same. Is this the way it's suppose to work, or have I completely missed something. I am very much a novice at this, and I'm just trying to learn.

Thanks again


Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<modification>
	<id>Default theme - Add Facebook Like in Top Menu</id>
	<version>1.0</version>
	<vqmver>2.0</vqmver>
	<author>Threebuoys</author>
	<file name="catalog/view/theme/default/template/common/header.tpl">
		<operation>
           	<search position="after"><![CDATA[<div class="links">
]]></search>     
         <add><![CDATA[<iframe src="//www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.three-buoys.com/cart/&send=false&layout=button_count&width=90&show_faces=false&action=like&colorscheme=light&font&height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:90px; height:21px; " allowTransparency="true"></iframe>
]]></add>
		</operation>
		<operation>
           	<search position="after"><![CDATA[<a href="<?php echo $checkout; ?>"><?php echo $text_checkout; ?></a>
]]></search>     
         <add><![CDATA[<iframe src="//www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.three-buoys.com/cart/&send=false&layout=button_count&width=90&show_faces=false&action=like&colorscheme=light&font&height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:90px; height:21px; " allowTransparency="true"></iframe>
]]></add>
		</operation>
</file>
</modification>

David

v1.5.2.1; vqmod


Newbie

Posts

Joined
Mon Apr 09, 2012 10:53 am
Location - Avon, NC
Who is online

Users browsing this forum: No registered users and 22 guests