Gavin Simpson
Gavin Simpson

Reputation: 2832

OpenCart2 vqmod replace,before and after all replacing?

Please take a look at the following xml file in the vqmod folder.

<?xml version="1.0" encoding="UTF-8"?>
    <modification>
        <id>Drop Shipping</id>
        <version>2.0.0</version>
        <vqmver required="true">2.4.0</vqmver>
        <author>South Coast Hosting Services (Pty) Ltd</author>
        <file name="admin/language/*/common/menu.php">
            <operation error="log">
                <search><![CDATA[// Text]]></search>
                <add position="after"><![CDATA[
                $_['text_gdropship_menu'] = 'Drop Shipping';
                $_['text_gdropship_setup'] = 'Drop Shipping Setup';
                ]]></add>
            </operation>
        </file>
        <file name="admin/controller/common/menu.php">
            <operation error="log">
                <search ><![CDATA[$this->load->language('common/menu');]]></search>
                <add position="after"><![CDATA[
                $data['text_gdropship_setup'] = $this->language->get('text_gdropship_setup');
                $data['text_gdropship_menu'] = $this->language->get('text_gdropship_menu'); 
                ]]></add>
            </operation>
            <operation error="log">
                <search><![CDATA[$data['home'] = $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], 'SSL');]]></search>
                <add position="before"><![CDATA[
                    $data['gdropshipmenu'] = $this->url->link('custom/gdropship', 'token=' . $this->session->data['token'], 'SSL');
                    $data['home'] = $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], 'SSL');
                ]]></add>
            </operation>
        </file>
        <file name="admin/view/template/common/menu.tpl">
            <operation error="log">
                <search><![CDATA[<li id="system"><a class="parent"><i class="fa fa-cog fa-fw"></i> <span><?php echo $text_system; ?></span></a>]]></search>
                <add position="before"><![CDATA[<li><a class="parent"><i class="fa fa-share-alt fa-fw"></i><span><?php echo $text_gdropship_menu; ?><span></a>
        <ul>
            <li><a href="<?php echo $gdropshipmenu; ?>"><?php echo $text_gdropship_setup; ?></a></li>
        </ul><li id="system"><a class="parent"><i class="fa fa-cog fa-fw"></i> <span><?php echo $text_system; ?></span></a>]]></add>
            </operation>
        </file>
    </modification>

This runs perfectly, linking to an admin page create in this question. You will see that the position tags contain 'after' and 'before' options. My problem is (besides taking all day to figure this out and do these few lines) is that both these tags seem to replace instead of doing a before or after. Changing them to replace has no effect. Hence I just included the code I was 'After-ing'.

So my question is have I done something wrong with the above code? I would just like to clarify before proceeding with development so it does not bite me down the line. It could be just another OC2 newbie.

Thank you.

PS Perhapse considering what's new a new tag for Opencart2 is warranted?

Upvotes: 0

Views: 1239

Answers (1)

Jay Gilford
Jay Gilford

Reputation: 15151

There is nothing wrong with your vQmod searches or replaces. The issue is you've formatted the search and replace parameters to those of OCMod, with the position="XXX" in the <add> tag instead of the <search> tag as per vQmod's format. Swapping those should fix the problem

Upvotes: 2

Related Questions