connectcase Posted August 13, 2013 Share Posted August 13, 2013 (edited) Hi there, I am trying to add an extra menu item to my backoffice according to this document: http://doc.prestasho...ck-Office-Menus So when I click "Administration -> Menus -> Add New", it need to enter a Module. If I enter the name of an existing(!) module and save the whole thing, clicking on this new menu item gets me: "the controller adminnotfound is missing or invalid". I am sure the modulename is correct, cause I have checked it through "admin -> Modules -> search". I'm guessing this is because it is searching for the module in "/controllers/admin/", while it needs to be searching in "/modules/". However I cannot enter "/modules/<module_name>", cause it then complains "the module field is invalid" (because it won't accept slashes??) How do I get it to accept the right module? Edited August 13, 2013 by connectcase (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted August 13, 2013 Share Posted August 13, 2013 this module have got seaparate admin controller .php file? may i know the name of the module? i will check it Link to comment Share on other sites More sharing options...
connectcase Posted August 13, 2013 Author Share Posted August 13, 2013 I found out that it does not matter which module you choose. Try the "Homepage Image Slider" (homeslider) for example.... Link to comment Share on other sites More sharing options...
vekia Posted August 13, 2013 Share Posted August 13, 2013 yes, it's because this module hasn't got AdminTab controller. it's necessary, if modules hasn't got php file with "extends AdminTab controller" then it will not work Link to comment Share on other sites More sharing options...
connectcase Posted August 13, 2013 Author Share Posted August 13, 2013 So that means there is a lot more to do than just enter the module(folder)name? The manual is really unclear about that..... Link to comment Share on other sites More sharing options...
vekia Posted August 13, 2013 Share Posted August 13, 2013 can you show me the url to the doc ? here is another one: http://doc.prestashop.com/display/PS14/Creating+a+PrestaShop+module#CreatingaPrestaShopmodule-Creatingthemodule%27sback-officetab%2Canditsclass you've got there info that it's necessary to add "class AdminTest extends AdminTab" in separate .php file. Link to comment Share on other sites More sharing options...
connectcase Posted August 13, 2013 Author Share Posted August 13, 2013 The official (?) one: http://doc.prestashop.com/display/PS15/Administering+The+Back-Office#AdministeringTheBack-Office-Menus Link to comment Share on other sites More sharing options...
connectcase Posted August 14, 2013 Author Share Posted August 14, 2013 My new backoffice menu items should have a few subitems pointing to existing modules. So for all these subitems I should create a new module? That's a bit much innit? I decided to edit /admin/themes/default/template/header.tpl and just add links to the existing modules there. Link to comment Share on other sites More sharing options...
vekia Posted August 14, 2013 Share Posted August 14, 2013 you can create new admin in two ways. create a module with adminTab controller create separate adminTab controller you can take a look into the \controllers\admin directory you've got there list of the adminTab controllers. If you don't want to create module, you should create own admin controller file. Link to comment Share on other sites More sharing options...
BoKr Posted February 5, 2014 Share Posted February 5, 2014 Hi Vekia and others, I followed the instructions of the fine manual. Now I got the AdminTest Tab in Bo. I want to add some modules now. E.g., gsitemap / gshopping or so.... Can I add them to this parent menu AdminTest via creating the test.php in each of the modules folders? Sorry, but I still lack the logic and basics behind this since I never tried to deal with something like this behind the scenes. Perhaps I have to change 'test' --> 'gsitemap' `? Ehm, sorry, I really a bit ashamed but I do not get it at the moment how it works Perhaps I would be a bit quicker in understanding if I knew whether it is commanding to have a new table for each module. But well, we are dealing with classes... Test.php <?php class Test extends ObjectModel { /** @var string Name */ public $test; protected $fieldsRequired = array('test'); protected $fieldsSize = array('test' => 64); protected $fieldsValidate = array('test' => 'isGenericName'); protected $table = 'test'; protected $identifier = 'id_test'; public function getFields() { parent::validateFields(); $fields['test'] = pSQL($this->test); return $fields; } } ?> Link to comment Share on other sites More sharing options...
fhpresta Posted September 27, 2014 Share Posted September 27, 2014 I am also looking for an answer to this question how to simply add modules links to admin tabs. I know how to create tab controller for a main tab and then subtabs, but creating subtabs or sublinks is long process for many modules, but let say you made this effort and amended a few modules, but you have to do each time the module is upgraded. is there a way to add a main controller menu tab module and add many module links to that main tab at once. e.g. create db table and a form for that main tab module, and add other modules links to it. Please help thanks, Link to comment Share on other sites More sharing options...
ivanferrer Posted March 3, 2016 Share Posted March 3, 2016 I usually create a class within the module root, and access it through the menu setup this way. <?php require_once(PS_ADMIN_DIR.'/../classes/AdminTab.php'); class AdminMyModule extends AdminTab { private $module = 'my_module'; private $cookie; public function __construct() { global $cookie, $_LANGADM; $this->cookie = $cookie; $langFile = _PS_MODULE_DIR_.$this->module.'/'.Language::getIsoById(intval($this->cookie->id_lang)).'.php'; if (file_exists($langFile)) { require_once $langFile; foreach ($_MODULE as $key=>$value) { if (substr(strip_tags($key), 0, 5) == 'Admin') { $_LANGADM[str_replace('_', '', strip_tags($key))] = $value; } } } parent::__construct(); } public function display() { return $this->displayForm(); } public function displayForm($firstCall = true) { $tokenModules= Tools::getAdminToken('AdminModules'.(int)(Tab::getIdFromClassName('AdminModules')).(int)($this->cookie->id_employee)); echo '<section id="dashgoals_config" class="dash_config col-xs-12 col-md-12 text-center"> <center><p>Loading...</p><img src="/img/loader.gif" border="0"></center> </section> <script> function openConfig() { window.location.href=\'?controller=AdminModules&token='.$tokenModules.'&configure='.$this->module.'&tab_module=front_office_features&module_name='.$this->module.'\'; } (function(){ openConfig(); })(); </script>'; } } ?> Link to comment Share on other sites More sharing options...
ivanferrer Posted March 3, 2016 Share Posted March 3, 2016 class AdminMyDataController extends AdminController { public $toolbar_title; private static $table = 'my_table_data'; protected $statuses_array = array(); public function openAbandonedCart() { $this->bootstrap = true; $this->className = 'MyClassNameData'; $this->lang = false; $this->addRowAction('view'); $this->explicitSelect = true; $this->allow_export = true; $this->deleted = false; $this->context = Context::getContext(); parent::openAbandonedCart(); } public function initContent() { $this->show_toolbar = false; $this->display = 'view'; $urls = array(); $open_cli = array(); $collection = $this->getCollection(); if (count($collection)) { $columns = array_keys($collection[0]); } } else { $columns = array('Not data exists.'); } $this->context->smarty->assign(array( 'column_names' => $columns, 'collection' => $collection, 'title_page' => array($this->l('My Title Page')) )); $this->content = $this->context->smarty->createTemplate(__DIR__.'/templates/my_template.tpl', $this->context->smarty)->fetch(); parent::initContent(); } public function initToolbarTitle() { //header title $this->toolbar_title = array_unique($this->breadcrumbs); } public function getCollection() { $collection = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS(' SELECT field1, field2, field3 FROM `'._DB_PREFIX_.bqSQL(self::$table_name).'` tab LEFT JOIN `'._DB_PREFIX_.'cart` c ON (c.`id_cart` = tab.`id_cart`) WHERE tab.`id_cart` != 0 ORDER BY field1 DESC '); return $collection; } public function setMedia() { parent::setMedia(); } } This is another way. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now