Jump to content

Create A own tab


Indiesservice

Recommended Posts

thanks vekia,

but i write the this code is install() method in mymodule.php

 

if (!$id_tab)

{

$tab = new Tab();

$tab->class_name = 'my modules';

$tab->id_parent = 0;

 

 

$tab->name = 'my modules';

$tab->add();

}

but it not display the admin tab in back office please help me

Edited by Indiesservice (see edit history)
Link to comment
Share on other sites

For 1.5 I use something like that:

 

           $new_tab = new Tab();
    $new_tab->class_name = 'AdminWaitProducts';
    $new_tab->id_parent = Tab::getCurrentParentId();
    $new_tab->module = $this->name;
    $languages = Language::getLanguages();
    foreach ($languages as $language) {
	    $new_tab->name[$language['id_lang']] = 'Waiting list';
    }
    $new_tab->add();

Edited by Alexander Simonchik (see edit history)
  • Like 1
Link to comment
Share on other sites

  • 3 weeks later...

so, it was little misunderstanding...

 

if you want to create new tab in back office in menu, you should create tab in install() function of your module.

 

here is piece of code:

 

// Install Tabs
 $parent_tab = new Tab();
 $parent_tab->name = 'Main Tab Example';
 $parent_tab->class_name = 'AdminMainExample';
 $parent_tab->id_parent = 0; // Home tab
 $parent_tab->module = $this->name;
 $parent_tab->add();

 $tab = new Tab();
 $tab->name = 'Tab Example';
 $tab->class_name = 'AdminExample';
 $tab->id_parent = $parent_tab->id;
 $tab->module = $this->name;
 $tab->add();

  • Like 1
Link to comment
Share on other sites

thanks, vekia

it is working but we write the unistall() function following code

 

$id_tab = Tab::getIdFromClassName($this->ClassName);

 

if ($id_tab)

{

$tab = new Tab($id_tab);

$tab->delete();

}

but not remove the tab in backoffice when the mymodules is uninstall....

Link to comment
Share on other sites

Indiesservice, did you try write adminTab class name instead of $this->ClassName?

 

I meen something like that:

   $idTabs = array();
	$idTabs[] = Tab::getIdFromClassName('AdminMainExample');
	$idTabs[] = Tab::getIdFromClassName('AdminExample');
	foreach ($idTabs as $idTab) {
		if ($idTab) {
			$tab = new Tab($idTab);
			$tab->delete();
		}
	}

 

Regards

Edited by Alexander Simonchik (see edit history)
  • Like 1
Link to comment
Share on other sites

thanks,

it is working create modules with the tab.

but problem is when i creating

 

1. - I create /controllers/admin/AdminMyExampleController.php of mymodules folder like so

 

AdminMyexampleController extends AdminController{}

 

but it will dispaly this type of error

 

Class 'AdminMyExampleController' not found in mypath\classes\controller\Controller.php on line 128

 

please give me a solution of this problems

Edited by Indiesservice (see edit history)
Link to comment
Share on other sites

hi Alexander

when i creating the mymodules/controllers/admin/AdminMyExample.php of this code

AdminMyexampleController extends AdminController{

 

this->table = 'myexample';

$this->className = 'Example';

 

 

$this->fields_list = array(

'id_myexample' => array(

'title' => $this->l('ID'),

'align' => 'center',

'width' => 20

),

'first_name' => array(

'title' => $this->l('First Name'),

'width' => 'auto'

),);

 

}

it display the this type of error

 

[PrestaShopDatabaseException]

 

Unknown column 'a. id_myexample

' in 'order clause' SELECT SQL_CALC_FOUND_ROWS a.* FROM `ps_myexample` a WHERE 1 ORDER BY a.id_myexample ASC LIMIT 0,50

at line 605 in file classes/db/Db.php

 

how to solve this problem some guide me

Edited by Indiesservice (see edit history)
Link to comment
Share on other sites

thanks,

Kriystian Sorry it's my misunderstanding... i am fetch the wrong column name

my another question is

 

when we add the

 

public function renderList()

{

$this->addRowAction('delete');

return parent::renderList();

}

it will be display the icon delete but when i click this icon then it will be display the error ,like as

 

Class 'Example' not found in C:\wamp\www\prestashop\classes\controller\AdminController.php on line 1047

 

 

please help me

Edited by Indiesservice (see edit history)
Link to comment
Share on other sites

i write some code of myproblem

 

1. - I create /controllers/admin/AdminMyExampleController.php like so:

class AdminMyExampleController extends AdminController

{

	 $this->table = 'myexample';
	 $this->className = 'MyExample';
$this->fields_list = array(
			'id_myexample' => array(
				'title' => $this->l('ID'),
				'align' => 'center',
				'width' => 20
			),
				'name' => array(
				'title' => $this->l('name'),
				'align' => 'center',
				'width' => 20
			),...............
public function renderList()
{
	// Adds an Edit button for each result
	$this->addRowAction('edit');

	// Adds a Delete button for each result
	$this->addRowAction('delete');

	return parent::renderList();
}
}

 

2. I create /classes/MyExample.php like

class MyExampleCore extends ObjectModel{}

 

this is my code

Edited by Indiesservice (see edit history)
Link to comment
Share on other sites

hi i am registering a hook for mymodule.php file like as

 

public function install()
{
if (!parent::install() || !$this->installDB() || !$this->registerHook('productLeftColumn'))
		return false;
return true;
}
public function hookLeftColumnProduct($params)
{


	  return $this->display(__FILE__, 'view/template/hook/mymodule.tpl');
}

 

but it will not display the product page tpl file what is i do wrong please give me advice..

thanks

Edited by Indiesservice (see edit history)
Link to comment
Share on other sites

  • 1 year later...

Hello folks,

I have the follow prob in BO, horiz menu, have add a tab Google site map, via the BO function, now I want remove this tab, but I can even go the menu tab, to undo this mistake.

When I hit the tab menu, I get: Admincontroller not found...

Best regards,

Generaal

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