How to Create Admin Menu Link for Custom Admin Page opencart
- Article
- Comment (6)
how to create admin menu link for custom admin page opencart. The question comes when we create a custom page inside your opencart. Once you created a custom page you need to provide link from the admin menu bar. From that link will help your users to understand that the link will help them to reach your page.
Now , you have two options to implement the custom menu link creation
- Edit the core files of opencart
- Create links by using VqMod.
Here you have two choices. You can simply edit the core and add your links into it.Alternatively use VQmod to create better linking. Lets start with core files editing. 1. Edit the core files of opencart Open the following files based on the directory structure.
Admin/controller/common/header.php Admin/language/english/common/header.php Admin/view/template/common/header.tpl
Lets start with controller file. Open admin/controller/common/header.php and find the following line
$this->data['openbay_link_amazonus_links'] = $this->url->link('openbay/amazonus/itemLinks', 'token=' . $this->session->data['token'], 'SSL');
And add below the following line of code.
$this->data['kvc_custom_page'] = $this->url->link('module/kvc', 'token=' . $this->session->data['token'], 'SSL');
And one more thing in the same file. Find the following line of code
$this->data['text_recurring_profile'] = $this->language->get('text_recurring_profile');
and add below the following line of code.
$this->data['kv_custom_menu_item'] = $this->language->get('kv_custom_menu_item');
That’s it for controller file. Now, open your language file “ admin/language/english/common/header.php “. And add the following line of code into it.
$_['kv_custom_menu_item'] = 'KV Custom Page';
And , Finally open your template file ” admin/view/template/common/header.tpl “. Here you need to place the file where you want to add the menu item. I mean the position will be based on the order of the line. Here i add the link next to the dashboard . So it will be easy to view.
<li> <a href="<?php echo $kvc_custom_page; ?>" class="top"><?php echo $kv_custom_menu_item; ?></a></li>
That’s it, now your custom page is linked with your admin menu. But here is a problem. When you think to update your store . The changes will be vanished. Because you worked with Core files. So here is a alternative method.
2.Create links by using VqMod.
This will be useful and always helps you to get the link by using VQMod.
<modification> <id>Custom Page Admin Link. </id> <version>0.1</version> <vqmver>2.0</vqmver> <author>Kvvaradha</author> <file name="admin/controller/common/header.php"> <operation> <search position="after"><![CDATA[ $this->data['openbay_link_amazonus_links'] = $this->url->link('openbay/amazonus/itemLinks', 'token=' . $this->session->data['token'], 'SSL'); ]]></search> <add><![CDATA[ $this->data['kvc_custom_page'] = $this->url->link('module/kvc', 'token=' . $this->session->data['token'], 'SSL'); ]]></add> </operation> <operation> <search position="after"><![CDATA[ $this->data['text_recurring_profile'] = $this->language->get('text_recurring_profile'); ]]></search> <add><![CDATA[ $this->data['kv_custom_menu_item'] = $this->language->get('kv_custom_menu_item'); ]]></add> </operation> </file> <file name="admin/language/english/common/header.php"> <operation> <search position="after"><![CDATA[ $_['text_recurring_profile'] = 'Recurring Profiles'; ]]></search> <add><![CDATA[ $_['kv_custom_menu_item'] = 'KV Custom Page'; ]]></add> </operation> </file> <file name="admin/view/template/common/header.tpl"> <operation> <search position="after"><![CDATA[ <li id="dashboard"><a href="<?php echo $home; ?>" class="top"><?php echo $text_dashboard; ?></a></li> ]]></search> <add><![CDATA[ <li> <a href="<?php echo $kvc_custom_page; ?>" class="top"><?php echo $kv_custom_menu_item; ?></a></li> ]]></add> </operation> </file> </modification>
That’s it, you can download this VQMod file from extension directory of OpenCart.
Download Source
Thank you great tutorial. First one about creating permission worked perfect. But in this tutorial KV CUSTOM Page didnt worked. Actually there appeared menu item but this error occured.Permission Denied! But i gave a permission in the ceckbox KVC/firs for acces and modified.
Whats the problem?
You have to provide token and session for user group to get acess for custom page
I’v got the same problem… Permission Denied!…how to provide token and session for user group to get acess for custom page…plz show tutorial.
Here is an article which will help you to set Permissions while installing a module.
https://www.kvcodes.com/2014/07/set-opencart-custom-page-access-for-user-group/
I replaced this code you wrote $this->data[‘kvc_custom_page’] = $this->url->link(‘module/kvc’, ‘token=’ . $this->session->data[‘token’], ‘SSL’);
to this one and it worked.
$this->data[‘kvc_custom_page’] = $this->url->link(‘kvc/first’, ‘token=’ . $this->session->data[‘token’], ‘SSL’);
is that true or you have another solution to give us?
You can set access either programmatically or from the admin panel