Jump to content

New menu in Backoffice created by module


voylinux

Recommended Posts

Is it possible to make the whole process of adding a new menu item to backoffice using just a module?

 

I mean, not going to going to Administration > Menus , but everything via code, included in my module. I want to make that an automatic task to different installations just by installing the module.

 

Could anybody explain all the files and classes that would be necessary?

 

Thank you.

Link to comment
Share on other sites

Hello bellini13, thanks for the link I did not find that info before.

 

I was a little bit lost because I found a lot of diferent incomplete links. But in that one you point there is a lot of helpfull info.

 

 

Link to comment
Share on other sites

Hello, I have followed all indicatons I found in creating the custom tab in my module but I get the next error:

[PrestaShopException]Property Tab->name is empty
at line 878 in file classes/ObjectModel.php872. 
873. 				$message = $this->validateField($field, $value, $id_lang);
874. 				if ($message !== true)
875. 				{
876. 					if ($die)
877. 						throw new PrestaShopException($message);
878. 					return $error_return ? $message : false;
879. 				}
880. 			}
881. 		}

but I actuallky have a name defined as a tab property. This is my createTab method in my module installation definition:

$tab = new Tab();
$tab->name = 'whatever';
$tab->module = 'whatevermodule';
$tab->className = 'WhatEver';
$tab->id_parent = 0;
$tab->add();

Thank you for your help.

Link to comment
Share on other sites

I'm going to guess here that the Tab name is a language field, which means you cannot set the name field directly. 

 

You basically need to iterate through all the installed languages and set the name as an associative array.  I did not test this, but give it a try

foreach (Language::getLanguages(false) as $language)
     $tab->name[$language->id]='whatever';
Link to comment
Share on other sites

 

I'm going to guess here that the Tab name is a language field, which means you cannot set the name field directly. 

 

You basically need to iterate through all the installed languages and set the name as an associative array.  I did not test this, but give it a try

foreach (Language::getLanguages(false) as $language)
     $tab->name[$language->id]='whatever';

 

I understand your point. I think the problem is related to that. But changing to this code gives me same error.

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...