Search code examples
adminopencart2.xvqmod

How to Create Sub Menu under Product Menu in Opencart Admin


I am trying to create Sub menu under Product menu using VQMOD, but unfortunately i couldn't able to display it in admin. Please see below for the code i used to create menu using VQMOD.

<modification>
    <id>Add a link</id>
    <version>1.5.4</version>
    <vqmver>0.1</vqmver>
    <author>Nagamani Naresh</author>

    <!-- edit header controller -->
    <file name="admin/controller/common/header.php">
    <!-- create link to your page -->   
        <operation error="log">
            <search position="after"><![CDATA[$this->data['setting'] = $this->url->link('setting/store', 'token=' . $this->session->data['token'], 'SSL');]]></search>
            <add><![CDATA[
            $this->data['hello_world'] = $this->url->link('custom/helloworld', 'token=' . $this->session->data['token'], 'SSL');
            ]]></add>
        </operation>
    <!-- / -->
    </file>

    <!-- edit header template -->
    <file name="admin/view/template/common/header.tpl">
    <!-- add link to your page -->  
        <operation error="log">

            <search position="before" offset="1"><![CDATA[<ul class="right">]]></search>
            <add><![CDATA[
            <li><a class="top">Your link</a>
                <ul>
                    <li><a href="<?=$hello_world;?>">Hello World</a></li>
                </ul>
            </li>
            ]]></add>
        </operation>
    <!-- / -->
    </file> 

</modification>

Please share your Suggestions.

enter image description here


Solution

  • for opencart 2.0.X save this code as name.ocmod.xml and uplaod from admin

    <?xml version="1.0" encoding="utf-8"?>
    <modification>
    <code>extra admin menu</code>
    <name>test admin menu</name>
    <version>2.0</version>
    <author>codertj</author>
    <link>codertj.com</link>
    
    <!-- edit header controller -->
    <file name="admin/controller/common/menu.php">
    <!-- create link to your page -->   
        <operation error="log">
            <search><![CDATA[$data['setting'] = $this->url->link('setting/store', 'token=' . $this->session->data['token'], 'SSL');]]></search>
            <add position="after"><![CDATA[
            $data['hello_world'] = $this->url->link('custom/helloworld', 'token=' . $this->session->data['token'], 'SSL');
            ]]></add>
        </operation>
    </file>
    
    <!-- edit header template -->
    <file name="admin/view/template/common/menu.tpl">
    <!-- add link to your page -->  
        <operation error="log">
            <search><![CDATA[<li><a href="<?php echo $product; ?>"><?php echo $text_product; ?></a></li>]]></search>
            <add position="after"><![CDATA[
            <li><a href="<?php echo $hello_world;?>">Hello World</a></li>               
            ]]></add>
        </operation>    
    </file>