Jump to content

Controller config page


slonka
 Share

Recommended Posts

and if you want to create AdminController - then just copy sources of other controller, name it as (for example) AdminMyController

 

 

then in back offie under administrator > menus define new menu item to handle your AdminMyController


I know, I did that, but I want to know more about prestashop and I couldn't find an answer on google.

 

yes, because it isn't common solution :(

  • Like 1

Share this post


Link to post
Share on other sites

now i'm lost :( you said before that you want to create configuration page for your new controller. Now you're talking about "CMS Page + a module visible only on that page?"

 

 

if you want to create controller configuraiton page - you have to define separate controller for that (adminController) or just create module with configuration page where you will be able to define configuration forms. (http://doc.prestashop.com/display/PS15/Creating+a+PrestaShop+module)

Share this post


Link to post
Share on other sites

I was talking about creating custom pages in general (not this case, because it's already done, I've created a new controller and added configuration options via module). What's better, own controller, cms page and a module or is there a other way to do it.

 

OT: My client wants a page that only displays products that are "on sale" what's the quickest way to achieve it?

Share this post


Link to post
Share on other sites

everything depends on what you exactly expect.
If you want to create simple page - then you can use default prestashop tool preferenes > CMS.
if you want to create something more than simple static text page - in my opinion it is better to create the module with front controller class
 

My client wants a page that only displays products that are "on sale" what's the quickest way to achieve it?

 

you can create it with Product class and it's function named getPricesDrop. It is static function so you can use this code: Product::getPricesDrop(FUNCTION_PARAMS),

 

where the FUNCTION_PARAMS is a list of parameters, like: $this->context->language->id, (int)$this->p - 1, (int)$this->n, false, $this->orderBy, $this->orderWay

Share this post


Link to post
Share on other sites

What do you mean by "module with front controller class"? A module that extends FrontController? or something like that:

class wlasnyzestaw extends Module
{
  public $page = null;

  public function __construct()
  {
    $this->page = new FrontController();
    $this->page->php_self = 'wlasny-zestaw';
  }
Edited by slonka (see edit history)

Share this post


Link to post
Share on other sites

you can create module with front controller. It mean, that your module will have "separate" page in your front office.

 

here is an example of this class (it should be located in modules/YOUR_MODULE/controllers/front/pagename.php file:

class modulenamepagenameModuleFrontController extends ModuleFrontController {  public function initContent(){
    parent::initContent(); 
    $this->setTemplate('template-file.tpl'); 
  }
}

This code will create new page like http://yourdomain.com/module/modulename/pagename

and you will see there template-file.tpl.

 

you can pass there variables like in "module" hook (with smarty array).

 

 

of course with this front controller in module, you can also create a configuration page as you usually are able to create in "simple" module.

Share this post


Link to post
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
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More