Jump to content

How to create a custom page in admin panel?


Recommended Posts

how to create a new page in prestashop admin panel? I tried using creating a new admin controller file and in that set the template path and i created a menu using admin panel and there i mentioned the controller class name for that menu. when i try to open that menu it always shows that controller not found. can anyone help me, how to create a new page in prestashop admin panel? am using PS 1.5 version.

 

     <?php

class AdminPageController extends AdminController {
public function __construct()
{
parent::__construct();
}

public function initContent()
{
parent::initContent();
$this->setTemplate(_PS_THEME_DIR_.'mypage.tpl');
}
}

Link to comment
Share on other sites

In controllers/admin folder. Please suggest me any tutorial or just tell me the steps needed to do this, because really I don't know how to do this.I want to create a new page in admin panel and need to show some static information in that page.If you know the steps, explain here please..

Link to comment
Share on other sites

There is no other step (that I know) it should work this way :( Unless I'm overseeing something


Try this 

$this->setTemplate(_PS_THEME_DIR_.'mypage.tpl');

 

return parent::initContent();

 

instead of

 

parent::initContent();

$this->setTemplate(_PS_THEME_DIR_.'mypage.tpl');

Link to comment
Share on other sites

Still its not working @ Nemo. I am making mistake somewhere :( , I will see some more controllers files and try again.Really thanks for your reply ..

 

Do we need any class file for making this ? right now am working with only one controller file.

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

http://awesomescreenshot.com/0081ut4c68 please check the image in this link.  This is the file structure now.

<?php

class AdminPageController extends AdminController {

public function __construct()
	{
	 	$this->table = 'Page';
		$this->className = 'Page';
		$this->module = '';
	 	$this->lang = false;
		parent::__construct();
	}

	public function initContent()
	{
		print_r("hi, there??");
		//$this->setTemplate(_PS_THEME_DIR_.'mypage.tpl');
 
		//return parent::initContent();
	}
}
Link to comment
Share on other sites

Well, it's working then, but now that I think about it, you should *probably* (as i never added a template file this way) put the tpl file in your admin/theme/controllername folder.

 

Then, try something like the product controller


		$tpl = $this->createTemplate('specific_prices_shop_update.tpl');
		$tpl->assign(array(
			'option_list' => $res,
			'key_id' => 'id_group',
			'key_value' => 'name'
			)
		);

		$this->content = $tpl->fetch();
Link to comment
Share on other sites

Its not showing yet. I created a folder named "page" in admin/themes/default/controllers and put the file in folder like this page/mypage.tpl and page/helpers/view/view.tpl. but both methods are not showing. I tried like this..

public function initContent()
	{
		print_r("hi, there??");
		$tpl = $this->createTemplate('mypage.tpl');
		$this->content = $tpl->fetch();
 		//return parent::initContent();
	}
Link to comment
Share on other sites

I tried that one also, Its not showing yet. It seems that fetching the template file only the problem, other wise my echo statements printed there. and I tried with one more function as same as in products controller, but that also not working.  :(

Link to comment
Share on other sites

  • 2 weeks later...

Hi Nemo...

 

Thanks for your reply. I got the answer.. here it is.

 

create controllers/admin/AdminPageController.php with the follwing content:

  class AdminPageController extends AdminController
    {
        public function initContent()
        {
            parent::initContent();
            $smarty = $this->context->smarty;

            $smarty->assign('test', 'test1');

        }
    }

Delete: /cache/class_index.php

Create: admin\themes\default\template\controllers\page\content.tpl

zzz{$test}zzz

At BackOffice -> Administration -> Menus -> [Add New]:

Name: Page
Class: AdminPage
Parent: Catalog

Click the [save] button and the menu item should appear at the "Catalog" menu.

 

Hope It may help someone.

  • Like 3
  • Thanks 1
Link to comment
Share on other sites

  • 1 month later...
  • 1 month later...

Hi Nemo...

 

Thanks for your reply. I got the answer.. here it is.

 

create controllers/admin/AdminPageController.php with the follwing content:

  class AdminPageController extends AdminController
    {
        public function initContent()
        {
            parent::initContent();
            $smarty = $this->context->smarty;

            $smarty->assign('test', 'test1');

        }
    }

Delete: /cache/class_index.php

Create: admin\themes\default\template\controllers\page\content.tpl

zzz{$test}zzz

At BackOffice -> Administration -> Menus -> [Add New]:

Name: Page
Class: AdminPage
Parent: Catalog

Click the [save] button and the menu item should appear at the "Catalog" menu.

 

Hope It may help someone.

Thank you Milky!

Link to comment
Share on other sites

  • 8 months later...
  • 2 years later...
×
×
  • Create New...