简体   繁体   English

Prestashop在管理面板边栏菜单中添加新项目

[英]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 Prestashop版本:1.7.4.2

This is the currently sidebar menu in my prestashop: 这是我的prestashop中当前的侧边栏菜单:

变更前

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 . 正如我研究我发现,这需要一个controller才能被里边有如图所示放置在这里

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: 我需要的是一个硬编码的固定外部url地址,因此最终将是结果:

变更后

What I did is put paint inside the jpg that I had screenshot to illustrate my point. 我所做的是在具有截图的jpg内放置油漆以说明我的观点。 And when they clicked the text, it will redirect to external page (not controller, etc) like http://www.google.com . 当他们单击文本时,它将重定向到external page (not controller, etc)例如http://www.google.com

Is there a Form that I can hardcoded specific url and show it so that user can redirect when needed. 有没有一种可以对hardcoded specific url进行hardcoded specific url并显示的表格,以便用户可以在需要时重定向。

Sorry as this is only concept no php code provided, as I didn't know how to accomplish it. 抱歉,这只是没有提供php代码的概念,因为我不知道如何实现。

Thank You. 谢谢。

All items that are shown in the sidebar menu have to be an AdminController class and added in the tab of PrestaShop. 边栏菜单中显示的所有项目都必须是AdminController class并添加到PrestaShop的tab中。

Then, in your AdminController, you make the redirection: 然后,在AdminController中,进行重定向:

<?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 祝好运

You have two simple ways that don't needed to deep scan PrestaShop codes. 您可以使用两种简单的方法来深度扫描PrestaShop代码。

1- On your module => admin controller: 1-在您的模块=>管理控制器上:

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

2- on your module main php file: 2-在您的模块主php文件上:

-- add "back office header" hook -添加“后台标头”挂钩

-- load jQuery file in this hook -在此挂钩中加载jQuery文件

-- change URL of your controller by jquery -通过jquery更改控制器的URL

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM