Redirect prestashop 1.7,如何在admintab上添加模块的配置链接?

Redirect prestashop 1.7,如何在admintab上添加模块的配置链接?,redirect,module,configuration,controller,prestashop,Redirect,Module,Configuration,Controller,Prestashop,我已经创建了一个模块,我想在admintab(左侧)中看到他。但是当点击链接时,我想重定向到模块的配置 这里有很多图片可以帮助你理解 我的管理员选项卡 当我点击链接我的页面 但我想转到我的配置模块 我已创建AdminYoutubeHomeController 在这种情况下,我如何重定向到我的模块?我搜索了一下,但什么也没找到 提前感谢在模块上查看创建adminCOntroller的链接: 在Prestashop中,在创建模块时,我们主要需要创建管理控制器。在模块中,要使管理员控制器正常工

我已经创建了一个模块,我想在admintab(左侧)中看到他。但是当点击链接时,我想重定向到模块的配置

这里有很多图片可以帮助你理解

我的管理员选项卡

当我点击链接我的页面

但我想转到我的配置模块

我已创建AdminYoutubeHomeController

在这种情况下,我如何重定向到我的模块?我搜索了一下,但什么也没找到


提前感谢

在模块上查看创建adminCOntroller的链接:


在Prestashop中,在创建模块时,我们主要需要创建管理控制器。在模块中,要使管理员控制器正常工作,我们必须在_DB_PREFIX_.
选项卡
'表中创建该管理员控制器类的条目。一般来说,我们在安装模块时会输入所有这些条目

因此,如果您在模块中创建管理控制器,您可以使用两种情况创建它-

您想为管理员控制器创建一个选项卡。 您希望创建管理控制器,而不为其创建选项卡

例如,您需要一个在点击链接时打开的控制器,可能还有许多其他情况

让我们通过示例了解这两种情况的过程-

让我们创建一个名为inatallTab()的函数,该函数在模块的管理控制器的“tab”表中创建条目

// Lets you want to create a child tab under 'Shipping' Tab. As we know Shipping Tab's class name is 'AdminParentShipping'
$this->installTab('AdminMyControllerName', 'My Tab Name', 'AdminParentShipping');

// Lets you want to create a parent tab. Then call the installTab() like below example-
$this->installTab('AdminMyControllerName', 'My Parent Tab Name');
案例1:带选项卡的管理员控制器

/*
* 2007-2016 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
*  @author PrestaShop SA <contact@prestashop.com>
*  @copyright  2007-2016 PrestaShop SA
*  @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*/
public function installTab($yourControllerClassName, $yourTabName, $tabParentControllerName = false)
{
    $tab = new Tab();
    $tab->active = 1;
    $tab->class_name = $yourControllerClassName; 
    // e.g. $yourControllerClassName = 'AdminMyControllerName'
    // Here $yourControllerClassName is the name of your controller's Class

    $tab->name = array();

    foreach (Language::getLanguages(true) as $lang) {

        $tab->name[$lang['id_lang']] = $yourTabName;
        // e.g. $yourTabName = 'My Tab Name'
        // Here $yourTabName is the name of your Tab
    }

    if ($tab_parent_controller_name) {

        $tab->id_parent = (int) Tab::getIdFromClassName($tabParentControllerName);
        // e.g. $tabParentControllerName = 'AdminParentAdminControllerName'
        // Here $tabParentControllerName  is the name of the controller under which Admin Controller's tab you want to put your controller's Tab

    } else {

        // If you want to make your controller's Tab as parent Tab in this case send id_parent as 0
        $tab->id_parent = 0;
    }

    // $this->name is the name of your module to which your admin controller belongs.
    // As we generally create it in module's installation So you can get module's name by $this->name in module's main file

    $tab->module = $this->name;
    // e.g. $this->name = 'MyModuleName'

    $tab->add();
    // make an entry of your tab in the _DB_PREFIX_.'tab' table.
}
/*
*2007-2016年预赛
*
*许可证通知书
*
*此源文件受开放软件许可证(OSL 3.0)的约束
*与此包捆绑在文件LICENSE.txt中的。
*也可通过万维网访问以下URL:
* http://opensource.org/licenses/osl-3.0.php
*如果您没有收到许可证副本,并且无法
*通过万维网获取,请发送电子邮件
*到license@prestashop.com所以我们可以马上给你寄一份。
*
*免责声明
*
*如果要将PrestaShop升级到较新版本,请不要编辑或添加到此文件
*未来的版本。如果您希望为您的客户定制PrestaShop
*需求请参考http://www.prestashop.com 了解更多信息。
*
*@作者PrestaShop SA
*@版权所有2007-2016 PrestaShop SA
*@许可证http://opensource.org/licenses/osl-3.0.php  开放软件许可证(OSL 3.0)
*PrestaShop SA的国际注册商标和财产
*/
公共函数installTab($yourControllerClassName,$yourTabName,$tabParentControllerName=false)
{
$tab=新选项卡();
$tab->active=1;
$tab->class_name=$yourControllerClassName;
//例如,$yourControllerClassName='AdminMyControllerName'
//此处$yourControllerClassName是控制器类的名称
$tab->name=array();
foreach(语言::getLanguages(true)为$lang){
$tab->name[$lang['id\u lang']]=$yourTabName;
//例如,$yourTabName='My Tab Name'
//这里$yourTabName是您选项卡的名称
}
如果($tab\u parent\u controller\u name){
$tab->id\u parent=(int)tab::getIdFromClassName($tabParentControllerName);
//例如$tabParentControllerName='AdminParentAdminControllerName'
//此处$tabParentControllerName是要将控制器选项卡放在其下的控制器的名称
}否则{
//如果要将控制器的选项卡设为父选项卡,则在此情况下将id\u父选项卡设为0
$tab->id\u parent=0;
}
//$this->name是管理员控制器所属模块的名称。
//因为我们通常在模块的安装中创建它,所以您可以通过模块主文件中的$this->name来获取模块的名称
$tab->module=$this->name;
//例如,$this->name='MyModuleName'
$tab->add();
//在_DB_PREFIX_'tab'表中输入选项卡。
}
下面的屏幕截图帮助我们看看如何在后台创建子选项卡或父选项卡

案例2:不创建选项卡的管理控制器

/*
* 2007-2016 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
*  @author PrestaShop SA <contact@prestashop.com>
*  @copyright  2007-2016 PrestaShop SA
*  @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*/
public function installTab($yourControllerClassName, $yourTabName, $tabParentControllerName = false)
{
    $tab = new Tab();
    $tab->active = 1;
    $tab->class_name = $yourControllerClassName; 
    // e.g. $yourControllerClassName = 'AdminMyControllerName'
    // Here $yourControllerClassName is the name of your controller's Class

    $tab->name = array();

    foreach (Language::getLanguages(true) as $lang) {

        $tab->name[$lang['id_lang']] = $yourTabName;
        // e.g. $yourTabName = 'My Tab Name'
        // Here $yourTabName is the name of your Tab
    }

    if ($tab_parent_controller_name) {

        $tab->id_parent = (int) Tab::getIdFromClassName($tabParentControllerName);
        // e.g. $tabParentControllerName = 'AdminParentAdminControllerName'
        // Here $tabParentControllerName  is the name of the controller under which Admin Controller's tab you want to put your controller's Tab

    } else {

        // If you want to make your controller's Tab as parent Tab in this case send id_parent as 0
        $tab->id_parent = 0;
    }

    // $this->name is the name of your module to which your admin controller belongs.
    // As we generally create it in module's installation So you can get module's name by $this->name in module's main file

    $tab->module = $this->name;
    // e.g. $this->name = 'MyModuleName'

    $tab->add();
    // make an entry of your tab in the _DB_PREFIX_.'tab' table.
}
若您想在不创建模块中的选项卡的情况下创建管理控制器,那个么您必须对上面的代码稍作修改,该代码将在_DB_PREFIX_.'tab'表中创建管理控制器的条目

我们只需要对代码中的字段id\u父项传递s-1。让我们看看这个案例的代码

/*
* 2007-2016 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
*  @author PrestaShop SA <contact@prestashop.com>
*  @copyright  2007-2016 PrestaShop SA
*  @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*/
$tab = new Tab();
$tab->active = 1;
$tab->class_name = $class_name;
$tab->name = array();

foreach (Language::getLanguages(true) as $lang) {
    $tab->name[$lang['id_lang']] = $tab_name;
}

//If you don't want to create a tab for your admin controller then Pass id_parent value as -1.
$tab->id_parent = -1;

$tab->module = $this->name;

return $tab->add();
/*
*2007-2016年预赛
*
*许可证通知书
*
*此源文件受开放软件许可证(OSL 3.0)的约束
*与此包捆绑在文件LICENSE.txt中的。
*也可通过万维网访问以下URL:
* http://opensource.org/licenses/osl-3.0.php
*如果您没有收到许可证副本,并且无法
*通过万维网获取,请发送电子邮件
*到license@prestashop.com所以我们可以马上给你寄一份。
*
*免责声明
*
*如果要将PrestaShop升级到较新版本,请不要编辑或添加到此文件
*未来的版本。如果您希望为您的客户定制PrestaShop
*需求请参考http://www.prestashop.com 了解更多信息。
*
*@作者PrestaShop SA
*@版权所有2007-2016 PrestaShop SA
*@许可证http://opensource.org/licenses/osl-3.0.php  开放软件许可证(OSL 3.0)
*PrestaShop SA的国际注册商标和财产
*/
$tab=新选项卡();
$tab->active=1;
$tab->class\u name=$class\u name;
$tab->name=array();
foreach(语言::getLanguages(true)为$lang){
$tab->name[$lang['id\u lang']]=$tab\u name;
}
//如果不想为管理员控制器创建选项卡,请将id\u父值作为-1传递。
$tab->id\u parent=-1;
$tab->module=$this->name;
返回$tab->add();
如您所见,如果我们将_DB_PREFIX_u.'tab'表中的if id_parent值设置为-1,则不会为管理员控制器和管理员创建任何选项卡
class AdminPLevelController extends ModuleAdminController
{


    public function renderView()
    {
        Tools::redirectAdmin($this->context->link->getAdminLink('AdminHome'));
    }
  }
<?php

if (!defined('_PS_VERSION_')) {
    exit;
}

class Plevel extends Module
{
    public $tabs = array(
        array(
            'name' => 'Price Level', // One name for all langs
            'class_name' => 'AdminPLevel',/**this is class_name defined in above code*/
            'visible' => true,
            'parent_class_name' => 'ShopParameters',
        ));
    public function __construct()
    {
        $this->name="plevel";
        $this->tab="dashboard";
        $this->version="1.0.0";
        $this->author="javaheri.ghazaleh@gmail.com";
        $this->need_instance=0;
        $this->ps_versions_compliancy=array('min'=>'1.6','max'=>_PS_VERSION_);
        $this->bootstrap=true;
        $this->context=Context::getContext();
        $this->displayName=$this->l("plevel");
        $this->description=$this->l("change order print page");
        $this->confirmUninstall=$this->l('Are you sure you want to uninstall');
        parent::__construct();
    }

    public function install()
    {
        if (!parent::install())
            return false;
        return true;
    }

    public function uninstall()
    {
        if (!parent::uninstall())
            return false;
        return true;
    }


}