liejoes1
liejoes1

Reputation: 157

Prestashop add new item in Admin Panel Sidebar Menu

I have small problem on create a custom item inside Admin Panel Sidebar Menu.

Prestashop Version: 1.7.4.2

This is the currently sidebar menu in my prestashop:

Before Changes

I would like to add new item that links to external website. As I have researched I found out that, this need to be a controller in order to be placed inside there as shown here.

As example shown above, they need to create a new controller for that specific purpose. What I need is a hardcoded fixed external url address, so in the end this would be the result:

After Changes

What I did is put paint inside the jpg that I had screenshot to illustrate my point. And when they clicked the text, it will redirect to external page (not controller, etc) like http://www.google.com.

Is there a Form that I can hardcoded specific url and show it so that user can redirect when needed.

Sorry as this is only concept no php code provided, as I didn't know how to accomplish it.

Thank You.

Upvotes: 0

Views: 1779

Answers (2)

Mahdi Shad
Mahdi Shad

Reputation: 1447

You have two simple ways that don't needed to deep scan PrestaShop codes.

1- On your module => admin controller:

public function init()
{
    Tools::redirect('https://google.com');
}

2- on your module main php file:

-- add "back office header" hook

-- load jQuery file in this hook

-- change URL of your controller by jquery

Upvotes: 0

Agnonym
Agnonym

Reputation: 96

All items that are shown in the sidebar menu have to be an AdminController class and added in the tab of PrestaShop.

Then, in your AdminController, you make the redirection:

<?php

class AdminMyModuleRedirectController extends ModuleAdminController
{
    public function init()
    {
        Tools::redirect('https://www.google.com');
    }
}

You still can manually modify the template that shows the sidebar menu, but it's not recommended.

Good luck

Upvotes: 1

Related Questions