Jump to content

[SOLVED] How to create Root Admin tab by module


Mukesh Ravi

Recommended Posts

Hello All,

 

I want to create new tab (In Admin Area) by module. I have created root tab in prestashop1.5.3,1.5.4

here is code but it is not created in prestashop1.5.5.0. So please help me out of this problem.

 

<?php  
 
if(!defined('_PS_VERSION_'))
    exit;
    
class createadmintab extends Module
{
    public function __construct(){
        $this->name = 'createadmintab';
        $this->tab = 'front_office_features';
        $this->version = '1.5';
        $this->author = 'Mukesh G';
        $this->need_instance = 0;
        
        parent::__construct();
        
        $this->displayName = $this->l('Create Admin Tab Module.');
        $this->description = $this->l('Module shows how to create new admin tab then write code for module');
        $this->confirmUninstall = $this->l('Are you sure you want to delete this module ?');
    }
    
    public function install(){
            
        $parent_tab = new Tab();
        $parent_tab->name = 'New Tab';
        $parent_tab->class_name = 'AdminMainNewTab';
        $parent_tab->id_parent = 0;
        $parent_tab->module = $this->name;
        $parent_tab->add();
        if (!parent::install()
             || !$this->installModuleTab('submenu1', array((int)(Configuration::get('PS_LANG_DEFAULT'))=>'submenu1'), $parent_tab->id)
             || !$this->installModuleTab('submenu2', array((int)(Configuration::get('PS_LANG_DEFAULT'))=>'submenu2'), $parent_tab->id)
             || !$this->installModuleTab('submenu3', array((int)(Configuration::get('PS_LANG_DEFAULT'))=>'submenu3'), $parent_tab->id))
            return false;
        return true;
    }
    
    
    public function uninstall()
    {
        if (!parent::uninstall()
            || !$this->uninstallModuleTab('submenu1')
            || !$this->uninstallModuleTab('submenu2')
            || !$this->uninstallModuleTab('submenu3')
            || !$this->uninstallModuleTab('AdminMainNewTab'))
                return false;
        return true;
    }
    
    private function installModuleTab($tabClass, $tabName, $idTabParent)
    {
       // $idTab = Tab::getIdFromClassName($idTabParent);       
        $idTab = $idTabParent;
        $pass = true ;
        @copy(_PS_MODULE_DIR_.$this->name.'/logo.gif', _PS_IMG_DIR_.'t/'.$tabClass.'.gif');
        $tab = new Tab();
        $tab->name = $tabName;
        $tab->class_name = $tabClass;
        $tab->module = $this->name;
        $tab->id_parent = $idTab;
        $pass = $tab->save();
        return($pass);
    }
    
    private function uninstallModuleTab($tabClass)
    {
        $pass = true ;
        @unlink(_PS_IMG_DIR_.'t/'.$tabClass.'.gif');
        $idTab = Tab::getIdFromClassName($tabClass);
        if($idTab != 0)
        {
            $tab = new Tab($idTab);
            $pass = $tab->delete();
        }
        return($pass);
    }
}
?>

 

I am waiting for your response.

 

Thanks

 

Link to comment
Share on other sites

Hi Mukesh,

 

try this: (add red text)

    public function install(){
            
        $parent_tab = new Tab();
    foreach (Language::getLanguages(true) as $lang)
    $parent_tab->name[$lang['id_lang']] = 'New Tab';
        $parent_tab->class_name = 'AdminMainNewTab';
...
 
    }
    
hope this helps,
pascal
Link to comment
Share on other sites

  • 5 months later...

Hi lovemyseo,

Can you provide a link to your site, so we can see what goes wrong? Maybe this helps finding a solution...

 

pascal

Yes this is for 1.4.9 http://biophoretics.com/blotting-instruments/174-tv100-ebk-mini-electroblotter.html

 

and for 1.5.4 it is http://goelectrophoresis.com/newbiosite/blotting-instruments/174-tv100-ebk-mini-electroblotter.html

 

Thanks

 

Link to comment
Share on other sites

Hi lovemyseo,

 

I tried in firefox, chrome and safari,but here the tabs seem to be visible...

 

attachicon.gifbiophoretic tab.png

 

and

 

attachicon.gifgoelectro with tab.png

 

Did I misunderstand??

 

 

pascal

I solved the issue while I got answer from your side thanks meanwhile I have something more interesting

 

http://www.prestashop.com/forums/topic/315492-selecting-manufacturer-for-product-in-ps-154/

 

If you can answer to that would be great

 

Hi lovemyseo,

 

I tried in firefox, chrome and safari,but here the tabs seem to be visible...

 

attachicon.gifbiophoretic tab.png

 

and

 

attachicon.gifgoelectro with tab.png

 

Did I misunderstand??

 

 

pascal

Yes I solved the issue before I got answer from your side thanks for help

 

meanwhile could you please check another issue here

 

http://www.prestashop.com/forums/topic/315492-selecting-manufacturer-for-product-in-ps-154/

 

If you can help would be great

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...