Mathlight Mathlight - 11 months ago 116
PHP Question

OpenCart admin menu link url

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:


The code I have added:

<li><a class="top">Import / Export</a>
<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>

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

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

Answer Source

Check my answer here: - 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');


$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?