astraljr Posted October 15, 2012 Share Posted October 15, 2012 Hi just want to ask how can I add a new custom page e.g. mydomain.com/mycustomepage.php. I tried create the file with this content require(dirname(__FILE__).'/config/config.inc.php'); Tools::displayFileAsDeprecated(); Tools::redirect('index.php?controller=mycustomepage'.($_REQUEST ? '&'.http_build_query($_REQUEST, '', '&') : ''), __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently'); I add added the controller MycustompageController.php with this content class MycustompageCore extends FrontController { public $php_self = 'mycustomepage'; public function initContent() { parent::initContent(); $this->setTemplate(_PS_THEME_DIR_.'mycustomepage.tpl'); } } then i created the mycustomepage.tpl. This works before with PS 1.4 but now when I load the page there is nothing displayed. Please help. Thanks in advance 2 Link to comment Share on other sites More sharing options...
radovan Posted October 18, 2012 Share Posted October 18, 2012 Hi i have a same question with the same problem. i try the same think but also with the white page as result... Link to comment Share on other sites More sharing options...
praneth Posted November 20, 2012 Share Posted November 20, 2012 I would also like to know Link to comment Share on other sites More sharing options...
infoseek Posted November 27, 2012 Share Posted November 27, 2012 also have this issue,anyone who gives some help,thx! Link to comment Share on other sites More sharing options...
henkedo Posted November 27, 2012 Share Posted November 27, 2012 (edited) Hello. I'm on Prestashop version: 1.5.2.0 Here's how to make a custom page. Mines called `testpage`, folow these steps: 1. override/classes/controller/FrontController.php - added template variable to see which controller is used. <?php class FrontController extends FrontControllerCore { public function init() { parent::init(); $this->context->smarty->assign(currentController', get_class($this)); } } 2. testpage.php <?php require(dirname(__FILE__).'/config/config.inc.php'); Tools::displayFileAsDeprecated(); Tools::redirect('index.php?controller=testpage'.($_REQUEST ? '&'.http_build_query($_REQUEST, '', '&') : ''), __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently'); 3. testpage.tpl {include file="$tpl_dir./breadcrumb.tpl"} {include file="$tpl_dir./errors.tpl"} <h1>Testpage</h1> controller: {$currentController} <!-- Should be : TestpageController --> 4. controllers/front/TestpageController.php - NEW FILE! <?php class TestpageControllerCore extends FrontController { public $php_self = 'testpage'; public function initContent() { parent::initContent(); $this->setTemplate(_PS_THEME_DIR_.'testpage.tpl'); } } 5. Only if you use Friendly URLs : In PS admin > Prefrences > SEO & URLs Add new > Page = testpage , Title = Testpage , Friendly URL = testpage Thats it! Hope it helps someone. Edited November 27, 2012 by henkedo (see edit history) 4 Link to comment Share on other sites More sharing options...
jayanthan Posted February 19, 2013 Share Posted February 19, 2013 (edited) Hello. I'm on Prestashop version: 1.5.2.0 Here's how to make a custom page. Mines called `testpage`, folow these steps: 1. override/classes/controller/FrontController.php - added template variable to see which controller is used. <?php class FrontController extends FrontControllerCore { public function init() { parent::init(); $this->context->smarty->assign(currentController', get_class($this)); } } 2. testpage.php <?php require(dirname(__FILE__).'/config/config.inc.php'); Tools::displayFileAsDeprecated(); Tools::redirect('index.php?controller=testpage'.($_REQUEST ? '&'.http_build_query($_REQUEST, '', '&') : ''), __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently'); 3. testpage.tpl {include file="$tpl_dir./breadcrumb.tpl"} {include file="$tpl_dir./errors.tpl"} <h1>Testpage</h1> controller: {$currentController} <!-- Should be : TestpageController --> 4. controllers/front/TestpageController.php - NEW FILE! <?php class TestpageControllerCore extends FrontController { public $php_self = 'testpage'; public function initContent() { parent::initContent(); $this->setTemplate(_PS_THEME_DIR_.'testpage.tpl'); } } 5. Only if you use Friendly URLs : In PS admin > Prefrences > SEO & URLs Add new > Page = testpage , Title = Testpage , Friendly URL = testpage Thats it! Hope it helps someone. Hi henkedo its a great thing u shared..and one more thing,could you tell how to add this page in menu bar Edited February 20, 2013 by jayanthan (see edit history) Link to comment Share on other sites More sharing options...
henkedo Posted February 19, 2013 Share Posted February 19, 2013 Yes.In Admin just go top configuration of Module 'blocktopmenu' and add the page manually. Link to comment Share on other sites More sharing options...
jayanthan Posted February 20, 2013 Share Posted February 20, 2013 (edited) Yes.In Admin just go top configuration of Module 'blocktopmenu' and add the page manually. hi once again, I am using module "Top horizontal menu" for menu items.I couldn find any new button to add menu.do u have any idea. :-) [sOLVED]: Due to some CSS conflicts add new button was hidden. i found the way of adding that menu thanks. Edited February 20, 2013 by jayanthan (see edit history) Link to comment Share on other sites More sharing options...
Whispar1 Posted February 27, 2013 Share Posted February 27, 2013 Thanks for sharing this!! I am trying to add a simple gallerific script to a cms page with no luck - maybe this is the answer. Any idea if this syntax is the same for 1.5.3.1? For some reason it didn't like the changes to FrontController.php I stopped at that point :/ Link to comment Share on other sites More sharing options...
Bill Dalton Posted February 27, 2013 Share Posted February 27, 2013 (edited) I really don't understand why anyone would use this method rather than the built in CMS. I'd really like to know. Whispar1, are you using {literal}{/literal} tags with your java script ? http://customprestsh...inside-tpl.html Edited February 27, 2013 by Bill Dalton (see edit history) Link to comment Share on other sites More sharing options...
Whispar1 Posted February 27, 2013 Share Posted February 27, 2013 (edited) Good point Bill. The only reason I am wanting this is to add a photo thumbnail gallery. The problem with using the cms page is that it strips empty elements (which is needed for the gallery in my case) I have a thread here that discussed this as well as a bug fix for part of the problem on github: http://www.prestasho...ustom-cms-page/ I ended up creating a few js files and called them along with the custom css files in the CmsController.php file. I added to the empty DIVS to keep tinymce from striping the code - just a few more tweaks to conflicting css elements between the gallery css and themes default css and I am almost there. Edited February 27, 2013 by Whispar1 (see edit history) Link to comment Share on other sites More sharing options...
Bill Dalton Posted February 27, 2013 Share Posted February 27, 2013 Wow! I missed that thread. Glad they fixed that bug so quickly. If tinymce has a bug like this, next time could one just go to the database directly and edit the input that tinymce puts in the field? I mean this time they fixed the bug quickly but that isn't always the case. Of course you would need to manually update the database every time you used tinymce on that CMS, but I wonder if that would work. Regardless it now looks great. Really nice. Link to comment Share on other sites More sharing options...
Whispar1 Posted February 27, 2013 Share Posted February 27, 2013 Thanks Bill. I actually found the bug issue on another forum and thought I would post it here for others in case this issue comes up for others. What I am doing with this particular cms page is I keep a duplicate (with all the in their proper place to keep them from being striped by tinymce. I edit the content in Dreamweaver then copy the code into the cms page content box section using the html button. It's not pretty but the end result works. Link to comment Share on other sites More sharing options...
Bill Dalton Posted February 27, 2013 Share Posted February 27, 2013 Sure whatever works! I have used Dreamweaver experimenting with creating forms and working in a WYSIWYG view than switching to code and then just paste it right into ps_CMS_Lang, works a treat. Basically after the CMS page is created, go directly to Dreamweaver, then paste to the database. Tinymce is ok ... but it doesn't compare with Dreamweaver. Link to comment Share on other sites More sharing options...
henkedo Posted February 28, 2013 Share Posted February 28, 2013 (edited) I really don't understand why anyone would use this method rather than the built in CMS. I'd really like to know. I needed this to make a totally different layout than the default for 1 single CMS category Index page... This way i can have a unique template file (HTML) and for ex. JS slideshow etc. + also usefull if you want to do some custom PHP logic and DB querys .. Edited February 28, 2013 by henkedo (see edit history) Link to comment Share on other sites More sharing options...
spc Posted March 6, 2013 Share Posted March 6, 2013 Hello I´m using PS 1.5.3.1 and follow every step in the script you have for test page... All i can se is a BLANK page... I hope that you can help me.... FrontController.php <?php class FrontController extends FrontControllerCore { public function init() { parent::init(); $this->context->smarty->assign(currentController', get_class($this)); } } testpage.php <?php require(dirname(__FILE__).'/config/config.inc.php'); Tools::displayFileAsDeprecated(); Tools::redirect('index.php?controller=testpage'.($_REQUEST ? '&'.http_build_query($_REQUEST, '', '&') : ''), __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently'); testpage.tpl {include file="$tpl_dir./breadcrumb.tpl"} {include file="$tpl_dir./errors.tpl"} <h1>Testpage</h1> controller: {$TestpageController} TestpageController.php <?php class TestpageControllerCore extends FrontController { public $php_self = 'testpage'; public function initContent() { parent::initContent(); $this->setTemplate(_PS_THEME_DIR_.'testpage.tpl'); } } In PS admin > Prefrences > SEO & URLs Add new > Page = testpage , Title = Testpage , Friendly URL = testpage PLEASE HELP Link to comment Share on other sites More sharing options...
pipo_ Posted March 13, 2013 Share Posted March 13, 2013 (edited) Hello I´m using PS 1.5.3.1 and follow every step in the script you have for test page... All i can se is a BLANK page... I hope that you can help me.... FrontController.php <?php class FrontController extends FrontControllerCore { public function init() { parent::init(); $this->context->smarty->assign(currentController', get_class($this)); } } testpage.php <?php require(dirname(__FILE__).'/config/config.inc.php'); Tools::displayFileAsDeprecated(); Tools::redirect('index.php?controller=testpage'.($_REQUEST ? '&'.http_build_query($_REQUEST, '', '&') : ''), __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently'); testpage.tpl {include file="$tpl_dir./breadcrumb.tpl"} {include file="$tpl_dir./errors.tpl"} <h1>Testpage</h1> controller: {$TestpageController} TestpageController.php <?php class TestpageControllerCore extends FrontController { public $php_self = 'testpage'; public function initContent() { parent::initContent(); $this->setTemplate(_PS_THEME_DIR_.'testpage.tpl'); } } In PS admin > Prefrences > SEO & URLs Add new > Page = testpage , Title = Testpage , Friendly URL = testpage PLEASE HELP FrontController.php goes to override\classes\controller\FrontController.php also, in FrontController.php is typo: <?php class FrontController extends FrontControllerCore { public function init() { parent::init(); $this->context->smarty->assign(currentController', get_class($this)); } } replace with <?php class FrontController extends FrontControllerCore { public function init() { parent::init(); $this->context->smarty->assign('currentController', get_class($this)); } } Edited March 13, 2013 by pipo_ (see edit history) Link to comment Share on other sites More sharing options...
Rhobur Posted May 29, 2013 Share Posted May 29, 2013 (edited) Hi, I am trying to create a new page following this thread too but i get an error "The website encountered an error while retrieving http://www.caprice-s...ertificat-cadou. It may be down for maintenance or configured incorrectly." Here is what I did: 1. Created FrontController.php to override/classes/controller/front <?php class FrontController extends FrontControllerCore { public function init() { parent::init(); $this--->context->smarty->assign('currentController', get_class($this)); } } 2. Created certificatcadou.php in / : require(dirname(__FILE__).'/config/config.inc.php'); Tools::displayFileAsDeprecated(); Tools::redirect('index.php?controller=certificatcadou'.($_REQUEST ? '&'.http_build_query($_REQUEST, '', '&') : ''), __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently'); 3. Created certificatcadou.tpl in /themes/mytheme : {include file="$tpl_dir./breadcrumb.tpl"} {include file="$tpl_dir./errors.tpl"} <h1>Testpage</h1> controller: {$CertificatCadouController} 4. Created CertificatCadouController.php in /controllers/front/ : <?php class CertificatCadouControllerCore extends FrontController { public $php_self = 'certificatcadou'; public function initContent() { parent::initContent(); $this->setTemplate(_PS_THEME_DIR_.'certificatcadou.tpl'); } } 5. Added In PS admin > Prefrences > SEO & URLs Add new > Page = certificatcadou , Title = Certificat Cadou , Friendly URL = certificat-cadou Still no luck!! Can you advise what could be wrong? Robert Edited May 29, 2013 by Caprice (see edit history) Link to comment Share on other sites More sharing options...
henkedo Posted May 29, 2013 Share Posted May 29, 2013 Hi Caprice. You've got a hyphen in the url http://www.caprice-shop.ro/certificat-cadou but your php page is called certificatcadou.php url rewriting won't find your page.. good lucko .henkedo 1 Link to comment Share on other sites More sharing options...
Rhobur Posted May 29, 2013 Share Posted May 29, 2013 (edited) Thanks henkedo! I have rewritten certificat-cadou to certificatcadou. Also I have modified the CertificatCadouController.php to <?php class TestpageControllerCore extends FrontController { public $php_self = 'certificatcadou'; public function initContent() { parent::initContent(); $this->setTemplate(_PS_THEME_DIR_.'certificatcadou.tpl'); } } Not working either, it gets me nuts :-) : Edit: the http://www.caprice-s...certificatcadou results in 404 not found Edit 2: enabling error messaging I have found : Fatal error: Class 'CertificatCadouController' not found in /home/sites/caprice-shop.ro/public_html/classes/controller/Controller.php on line 128 What is this? Shouls I move the new Controller file to /classes/controller/? Edited May 29, 2013 by Caprice (see edit history) Link to comment Share on other sites More sharing options...
jake7 Posted April 7, 2016 Share Posted April 7, 2016 Hi, Ive followed the example but I'm getting a File is deprecated error in classes/Tools.php on line 2611 . I'm using Prestashop version 1.6.1. What changes do I need to make for 1.6 please or is something else wrong? Link to comment Share on other sites More sharing options...
Recommended Posts