Jump to content

Recommended Posts

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 by connectcase (see edit history)
Link to comment
Share on other sites

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

you can create new admin in two ways.

  1. create a module with adminTab controller
  2. 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

  • 5 months later...

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

  • 7 months later...

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

  • 1 year later...

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

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

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