4

I'm verry new to OpenCart and I'm trying to make a module for it.

I want a link in the admin menu to the module I am creating thus I've edited this file:

/admin/view/template/common/header.tpl

The code I have added:

<li><a class="top">Import / Export</a>
    <ul>
        <li><a href="" target="_blank">Link 1</a></li>
        <li><a href="" target="_blank">Link 2</a></li>
        <li><a href="" target="_blank">Link 3</a></li>
    </ul>
</li>

My question is propably verry simple:

In the normal links the url for the <a href=""> is set like this:

<a href="<?php echo $report_customer_online; ?>">

How can i make an url to the right module with the token of OpenCart?

The module path is module/order_export.

If you need more info, feel free to ask...

shadyyx
  • 15,825
  • 6
  • 60
  • 95
Mathlight
  • 6,436
  • 17
  • 62
  • 107
  • 1
    It's worth noting that if you are planning to do this for sale you should use vQmod ([link](http://vqmod.com/)) for it rather than requiring people to edit files. Almost all carts have vQmod already installed on them – Jay Gilford May 15 '13 at 15:50
  • @JayGilford, thanks for the point out. Almost forgot about that. But now i know how it works, so using VQMod will not be that hard... Thank you anyway ;) – Mathlight May 16 '13 at 07:16

4 Answers4

10

Check my answer here: https://stackoverflow.com/a/16418443/598500 - I have answered for the very similar question, anyway the answer is the same as for Your question.

But to guide You more precisely:

language file /admin/language/<YOUR_LANGUAGE>/common/header.php add e.g.:

$_['text_my_module'] = 'My Module Title';

controller file /admin/controller/common/header.php add e.g.:

$this->data['text_my_module'] = $this->language->get('text_my_module');

and

$this->data['my_module'] = $this->url->link('module/order_export', 'token=' . $this->session->data['token'], 'SSL');

and finally the template file /admin/view/template/common/header.tpl add:

<a href="<?php echo $my_module; ?>" class="top"><?php echo $text_my_module; ?></a>

where applicable...

Is this the correct answer for You?

Community
  • 1
  • 1
shadyyx
  • 15,825
  • 6
  • 60
  • 95
1

It is simple to create. but you need to edit the following files and add some link works like what they said above. But it will be vanished. when you go with Opencart update. So here is a VQMod Link creation example and its extension. Try this/

http://kvcodes.com/2014/06/how-to-create-admin-menu-link-for-custom-admin-page-opencart/

varadha
  • 11
  • 1
  • Hi and welcome to Stack Overflow. While your answer remains here, the link might change or become otherwise unavailable. Please edit your answer to contain the essentials of the link, so it will remain helpful regardless of the link's state. – Noich Jun 17 '14 at 05:40
1

In Opencart 2:

language file /admin/language/<YOUR_LANGUAGE>/common/menu.php add e.g.:

$_['text_my_module'] = 'My Module Title';

controller file /admin/controller/common/menu.php add e.g.:

$data['text_my_module'] = $this->language->get('text_my_module');

and

$data['my_module'] = $this->url->link('catalog/my_module', 'token=' . $this->session->data['token'], 'SSL');

and finally the template file /admin/view/template/common/menu.tpl add:

<li><a href="<?php echo $my_module; ?>">text_my_module</a></li>

where applicable...

webdevanuj
  • 675
  • 12
  • 22
0

Thanks to Anuj!

I did it with OpenCart 2.3 and the files to edit are column-left instead of menu.

And if you want your link to look like the other main categories here is the code with the class :

<li><a href="<?php echo $my_module; ?>"><i class="fa fa-clock-o fw"></i><span><?php echo $text_my_module ?></span></a></li>

Note that I also included an icon from Font Awesome into the class of < i >

Stephie
  • 1
  • 1