Post by Rebecka » Wed Nov 02, 2011 4:24 am

I really want to learn how I make modifications using vQmod. I've started to read this http://code.google.com/p/vqmod/wiki/Scripting I shall begin by replacing an image file to start with something simple.

These are my first questions:
modification / version

This is the version of the mod.
Format: Number and Decimal (1.0.0) (Informational)
Uh yeah, what is meant by "the version of the mod"?
Does that mean I should invent a version or is it perhaps my version of OpenCart?
modification / vqmver

This is the minimum required version of VirtualQMod needed for the script to work.
Format: Number and Decimal (1.0.0) (Informational)
Here I specify which version of vQmod I use?
Will the script work in the latest version of vQmod if I follow the documentation mentioned above?

Thanks in advance!

Rebecka went over to PrestaShop.


Active Member

Posts

Joined
Sun Sep 18, 2011 4:49 am
Location - Sweden

Post by marvmen21 » Wed Nov 02, 2011 4:52 am

yes and yes to your questions. You have already answered them yourself. ;)

You want to thank me for my time! :) Click here to donate


Active Member

Posts

Joined
Tue Nov 09, 2010 4:54 am

Post by Rebecka » Wed Nov 02, 2011 5:25 am

What is yes in the first question? Invent a version of my mod or my version of OpenCart?

Second question I understand what you meant by yes. :)

Rebecka went over to PrestaShop.


Active Member

Posts

Joined
Sun Sep 18, 2011 4:49 am
Location - Sweden

Post by Xsecrets » Wed Nov 02, 2011 6:12 am

Rebecka wrote:I really want to learn how I make modifications using vQmod. I've started to read this http://code.google.com/p/vqmod/wiki/Scripting I shall begin by replacing an image file to start with something simple.

These are my first questions:


Uh yeah, what is meant by "the version of the mod"?
Does that mean I should invent a version or is it perhaps my version of OpenCart?
yes this is your version number, so you might start with 1.0.0 and then if you make changes make it 1.0.1 Doesn't really matter. Doesn't affect anything. It's just there for reference for people using the mod later on so you can tell them to look at it and then go oh you're on version 1.0.1 here's version 1.0.2 where I fixed some stuff.

Here I specify which version of vQmod I use?
Will the script work in the latest version of vQmod if I follow the documentation mentioned above?

Thanks in advance!
Yes you specify the version of vqmod you are using. In general scripts will always work with newer versions of vqmod. At least so far it has maintained complete backward compatability, however new features are often added in new vqmod versions. So for instance if you used 1.2.3 and used the wildcard feature for templates then it would not work for someone who was using vqmod 1.0.8, however I have several vqmods in distribution that still say 1.0.8 for the vqmod version because that was the version when I developed them and they do not use any of the newer features, but they still work perfectly fine in the latest version.

OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter


Guru Member

Posts

Joined
Sun Oct 25, 2009 3:51 am
Location - FL US

Post by Rebecka » Wed Nov 02, 2011 6:19 am

Thank you very much for explaining!

Rebecka went over to PrestaShop.


Active Member

Posts

Joined
Sun Sep 18, 2011 4:49 am
Location - Sweden

Post by Rebecka » Wed Nov 02, 2011 6:24 am

Xsecrets wrote:yes this is your version number, so you might start with 1.0.0 and then if you make changes make it 1.0.1 Doesn't really matter. Doesn't affect anything. It's just there for reference for people using the mod later on so you can tell them to look at it and then go oh you're on version 1.0.1 here's version 1.0.2 where I fixed some stuff.

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
What version is this by the way? Same as above?

Rebecka went over to PrestaShop.


Active Member

Posts

Joined
Sun Sep 18, 2011 4:49 am
Location - Sweden

Post by Xsecrets » Wed Nov 02, 2011 6:31 am

Rebecka wrote:
Xsecrets wrote:yes this is your version number, so you might start with 1.0.0 and then if you make changes make it 1.0.1 Doesn't really matter. Doesn't affect anything. It's just there for reference for people using the mod later on so you can tell them to look at it and then go oh you're on version 1.0.1 here's version 1.0.2 where I fixed some stuff.

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
What version is this by the way? Same as above?
yes version is your version number vqmver is the vqmod version.

OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter


Guru Member

Posts

Joined
Sun Oct 25, 2009 3:51 am
Location - FL US

Post by Rebecka » Wed Nov 02, 2011 7:00 am

Here is a new type of question.

I shall begin by replace an image file. Were do I put the image file that will replace the original file? I know that if I want to replace a code, I put the new code in the script. But if I replace an image, I suppose I must have it uploaded somewhere?

Or is it unnecessary/wrong to use vQmod to replace image files as well?

Rebecka went over to PrestaShop.


Active Member

Posts

Joined
Sun Sep 18, 2011 4:49 am
Location - Sweden

Post by Xsecrets » Wed Nov 02, 2011 7:46 am

Rebecka wrote:Here is a new type of question.

I shall begin by replace an image file. Were do I put the image file that will replace the original file? I know that if I want to replace a code, I put the new code in the script. But if I replace an image, I suppose I must have it uploaded somewhere?

Or is it unnecessary/wrong to use vQmod to replace image files as well?
well vqmod cannot actually replace the image. You can change/replace the code to call a different image, but as you said you have to have that image uploaded to the server somewhere, or on another server somewhere. vqmod cannot inject a binary image only change the text.

OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter


Guru Member

Posts

Joined
Sun Oct 25, 2009 3:51 am
Location - FL US

Post by Rebecka » Wed Nov 02, 2011 9:16 am

That's what I thought. I just replace the original file in the usual way.

Rebecka went over to PrestaShop.


Active Member

Posts

Joined
Sun Sep 18, 2011 4:49 am
Location - Sweden

Post by Qphoria » Wed Nov 02, 2011 9:03 pm

Xsecrets wrote:
Rebecka wrote:
Xsecrets wrote:yes this is your version number, so you might start with 1.0.0 and then if you make changes make it 1.0.1 Doesn't really matter. Doesn't affect anything. It's just there for reference for people using the mod later on so you can tell them to look at it and then go oh you're on version 1.0.1 here's version 1.0.2 where I fixed some stuff.

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
What version is this by the way? Same as above?
yes version is your version number vqmver is the vqmod version.
What? No.
That is the xml version number, that is just meant to sit at the top of the file for xml conformance and it at the top of any xml file. That just has to be there and will never change. Your version number is set in the <version></version> tag

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Xsecrets » Wed Nov 02, 2011 9:08 pm

yeah Q is right. I wasn't paying enough attention to what you posted since you only posted a snippet I was thinking of the version tag.

OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter


Guru Member

Posts

Joined
Sun Oct 25, 2009 3:51 am
Location - FL US

Post by Qphoria » Wed Nov 02, 2011 9:09 pm

Xsecrets wrote:yeah Q is right.
Well that goes without saying :laugh: :joker: :crazy:

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Rebecka » Thu Nov 03, 2011 1:58 am

Qphoria wrote:
Xsecrets wrote:
Rebecka wrote:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
What version is this by the way? Same as above?
yes version is your version number vqmver is the vqmod version.
What? No.
That is the xml version number, that is just meant to sit at the top of the file for xml conformance and it at the top of any xml file. That just has to be there and will never change. Your version number is set in the <version></version> tag
Thank you for pointing out!

Rebecka went over to PrestaShop.


Active Member

Posts

Joined
Sun Sep 18, 2011 4:49 am
Location - Sweden

Post by Rebecka » Thu Nov 03, 2011 2:29 am

Here is my first attempt. To see if I've been thinking right.

It says
modification / file
There can be multiple file tags in a single xml file. Each file can have its own set of operations
Does that mean that this

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<modification>
        <id>Replace 123 with ABC</id>
        <version>1.0.0</version>
        <vqmver>1.0.9</vqmver>
        <author>qphoria</author>
        
        <file name="relative/path/myfile.php">
                <operation>
                
                        <search position="replace"><![CDATA[
                        $var = '123';
                        ]]></search>
                        
                        <add><![CDATA[
                        $var = 'ABC';
                        ]]></add>
                        
                </operation>
        </file> 
</modification>
Can look like this?

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<modification>
        <id>Replace 123 with ABC</id>
        <version>1.0.0</version>
        <vqmver>1.0.9</vqmver>
        <author>qphoria</author>
        
        <file name="relative/path/myfile.php">
                <operation>
                
                        <search position="replace"><![CDATA[
                        $var = '123';
                        ]]></search>
                        
                        <add><![CDATA[
                        $var = 'ABC';
                        ]]></add>
                        
                </operation>
        </file> 

        <file name="relative/path/myfile2.php">
                <operation>
                
                        <search position="replace"><![CDATA[
                        $var = '123';
                        ]]></search>
                        
                        <add><![CDATA[
                        $var = 'ABC';
                        ]]></add>
                        
                </operation>
        </file>
</modification>
If so, I have made the following

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<modification>
        <id>Replace categories with information</id>
        <version>1.5.1.3</version>
        <vqmver>2.1.4</vqmver>
        <author>Rebecka</author>
        
        <file name="catalog/controller/common/header.php">
                <operation>
                
                        <search position="replace"><![CDATA[
                        $var = '$this->load->model('catalog/category');
		$this->load->model('catalog/product');
		
		$this->data['categories'] = array();
					
		$categories = $this->model_catalog_category->getCategories(0);
		
		foreach ($categories as $category) {
			if ($category['top']) {
				$children_data = array();
				
				$children = $this->model_catalog_category->getCategories($category['category_id']);
				
				foreach ($children as $child) {
					$data = array(
						'filter_category_id'  => $child['category_id'],
						'filter_sub_category' => true	
					);		
						
					$product_total = $this->model_catalog_product->getTotalProducts($data);
									
					$children_data[] = array(
						'name'  => $child['name'] . ' (' . $product_total . ')',
						'href'  => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id'])	
					);					
				}
				
				// Level 1
				$this->data['categories'][] = array(
					'name'     => $category['name'],
					'children' => $children_data,
					'column'   => $category['column'] ? $category['column'] : 1,
					'href'     => $this->url->link('product/category', 'path=' . $category['category_id'])
				);
			}
		}';
                        ]]></search>
                        
                        <add><![CDATA[
                        $var = '$this->load->model('catalog/information');
$this->data['informations'] = array();

foreach ($this->model_catalog_information->getInformations() as $result) {
$this->data['informations'][] = array(
       'title' => $result['title'],
   'href'  => $this->url->link('information/information', 'information_id=' . $result['information_id'])
);
}
$this->language->load('module/information');
   
   $this->data['text_contact'] = $this->language->get('text_contact');

$this->load->model('catalog/information');

$this->data['informations'] = array();

foreach ($this->model_catalog_information->getInformations() as $result) {
$this->data['informations'][] = array(
       'title' => $result['title'],
   'href'  => $this->url->link('information/information', 'information_id=' . $result['information_id'])
);
}
$this->data['contact'] = $this->url->link('information/contact');';
                        ]]></add>
                        
                </operation>
        </file> 

        <file name="catalog/view/theme/mystockimages/template/common/header.tpl">
                <operation>
                
                        <search position="replace"><![CDATA[
                        $var = '<!-- Main Menu Starts -->
			<?php if ($categories) { ?>
				<div id="menu">
					<ul>
					<!-- Menu Links Starts -->
						<?php foreach ($categories as $category) { ?>
							<li><a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a>
								<?php if ($category['children']) { ?>
								<!-- Dropdown Menu Links Starts -->
									<div>
										<?php for ($i = 0; $i < count($category['children']);) { ?>
											<ul>
												<?php $j = $i + ceil(count($category['children']) / $category['column']); ?>
												<?php for (; $i < $j; $i++) { ?>
													<?php if (isset($category['children'][$i])) { ?>
														<li>
															<a href="<?php echo $category['children'][$i]['href']; ?>">
																<?php echo $category['children'][$i]['name']; ?>
															</a>
														</li>
													<?php } ?>
												<?php } ?>
											</ul>
										<?php } ?>
									</div>
								<!-- Dropdown Menu Links Ends -->
								<?php } ?>						
							</li>
						<?php } ?>
					<!-- Menu Links Ends -->
					</ul>
				</div>
			<?php } ?>
		<!-- Main Menu Ends -->';
                        ]]></search>
                        
                        <add><![CDATA[
                        $var = '<!-- Main Menu Starts -->
         <?php if ($informations) { ?>
            <div id="menu">
               <ul>
               <!-- Menu Links Starts -->
                  <?php foreach ($informations as $information) { ?>
                     <li><a href="<?php echo $information['href']; ?>"><?php echo $information['title']; ?></a></li>
                  <?php } ?>
<li><a href="<?php echo $contact; ?>"><?php echo $text_contact; ?></a></li>
               <!-- Menu Links Ends -->
               </ul>
            </div>
         <?php } ?>
      <!-- Main Menu Ends -->';
                        ]]></add>
                        
                </operation>
        </file>
</modification>
Have I done right?

Rebecka went over to PrestaShop.


Active Member

Posts

Joined
Sun Sep 18, 2011 4:49 am
Location - Sweden

Post by Qphoria » Thu Nov 03, 2011 3:11 am

Close, but no.
<search> can only be a single line.

<add> can be multiple lines

If you want to replace multiple lines, you have to think outside the box

For example:

if you have this:

Code: Select all

$data = array();
foreach ($results as $key => $value) {
    $data[$key] = $value; 
}
and you want to replace it with this:

Code: Select all

while ($next = next($results)) {
    $value = key($data);
    $data[$key] = $value;
}
Then you would need to match the the first line, and use the offset attribute for each additional line to replace
In this case the first line is $data = array(); and there are 3 lines after that that make up the rest of what you want to find.

So

Code: Select all

<search position="replace" offset="3">
$data = array();
</search>

<add>
while ($next = next($results)) {
    $value = key($data);
    $data[$key] = $value;
}
</add>

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Rebecka » Thu Nov 03, 2011 4:23 am

I do not really understand but I'll try. :-\
Last edited by Rebecka on Thu Nov 03, 2011 7:53 pm, edited 1 time in total.

Rebecka went over to PrestaShop.


Active Member

Posts

Joined
Sun Sep 18, 2011 4:49 am
Location - Sweden

Post by Rebecka » Thu Nov 03, 2011 8:37 am

I also wonder how I do if I want to modify the stylesheet when I want to replace and add.

I would for example like to remove breadcumb, border and background of pagination and change the padding of pagination.
Last edited by Rebecka on Thu Nov 03, 2011 7:28 pm, edited 1 time in total.

Rebecka went over to PrestaShop.


Active Member

Posts

Joined
Sun Sep 18, 2011 4:49 am
Location - Sweden

Post by Qphoria » Thu Nov 03, 2011 9:22 am

You best read the "Limitations" section here:
http://code.google.com/p/vqmod/wiki/About

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Rebecka » Thu Nov 03, 2011 7:31 pm

Thanks for the link!

Back to header.php and header.tpl then.

Rebecka went over to PrestaShop.


Active Member

Posts

Joined
Sun Sep 18, 2011 4:49 am
Location - Sweden
Who is online

Users browsing this forum: No registered users and 3 guests