slonka Posted September 3, 2013 Share Posted September 3, 2013 Hello! I've created a controller to handle my custom page, now I want to create a configuration page like I would do for a module. How can I do that? Link to comment Share on other sites More sharing options...
vekia Posted September 4, 2013 Share Posted September 4, 2013 in this case you need to create also adminController tab or just create a module with your new controller and simple configuration for it like for module. Link to comment Share on other sites More sharing options...
slonka Posted September 4, 2013 Author Share Posted September 4, 2013 vekia: Can you link to a tutorial or tell me how do I create adminController? (googling 'prestashop admin controller' doesn't help). Prestashop really needs a documentation upgrade. Link to comment Share on other sites More sharing options...
vekia Posted September 4, 2013 Share Posted September 4, 2013 you can create for example module with configuration page - and there you can define forms to set up settings of your controller Link to comment Share on other sites More sharing options...
slonka Posted September 4, 2013 Author Share Posted September 4, 2013 I know, I did that, but I want to know more about prestashop and I couldn't find an answer on google. Link to comment Share on other sites More sharing options...
vekia Posted September 4, 2013 Share Posted September 4, 2013 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 1 Link to comment Share on other sites More sharing options...
slonka Posted September 4, 2013 Author Share Posted September 4, 2013 So what's the best way to create customizable pages? CMS Page + a module visible only on that page? Link to comment Share on other sites More sharing options...
vekia Posted September 4, 2013 Share Posted September 4, 2013 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) Link to comment Share on other sites More sharing options...
slonka Posted September 4, 2013 Author Share Posted September 4, 2013 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? Link to comment Share on other sites More sharing options...
vekia Posted September 4, 2013 Share Posted September 4, 2013 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 Link to comment Share on other sites More sharing options...
slonka Posted September 4, 2013 Author Share Posted September 4, 2013 (edited) 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 September 4, 2013 by slonka (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted September 4, 2013 Share Posted September 4, 2013 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. 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