Sly Crespo Posted April 25, 2010 Share Posted April 25, 2010 Hello ! I'm new to PrestaShop and that question may be stupid. I would like to add a custom page to my shop and a corresponding link on the top of the page. How do I do this ?Thanks Link to comment Share on other sites More sharing options...
razaro Posted April 25, 2010 Share Posted April 25, 2010 You could go to Back Office » Tools » CMS and click on Add new.And use some module to add it to homepage.Another way is to create for example newpage.php <?php include(dirname(__FILE__).'/config/config.inc.php'); include(dirname(__FILE__).'/header.php'); $smarty->display(_PS_THEME_DIR_.'newpage.tpl'); include(dirname(__FILE__).'/footer.php'); ?> and save it to main prestashiop folder and then in your theme folder create file newpage.tpl.Both files are in attachment. newpage.zip 9 Link to comment Share on other sites More sharing options...
Sly Crespo Posted April 25, 2010 Author Share Posted April 25, 2010 Thanks razaro for your fast reply... But i'm a noob and don't know how to do that.. Can you explain it a little bit more precisely. Sorry about my english and Thanks. Sly Link to comment Share on other sites More sharing options...
ladivito Posted April 26, 2010 Share Posted April 26, 2010 useful tips.....thanks Link to comment Share on other sites More sharing options...
sircolla Posted October 30, 2010 Share Posted October 30, 2010 hello razaro,could you tell me which module to use to add new pages?thanks Link to comment Share on other sites More sharing options...
razaro Posted October 30, 2010 Share Posted October 30, 2010 You can add links to new pages with some modules, if you create CMS page you can use Info block module and if you created php page use Link block module.And this module can do both. Link to comment Share on other sites More sharing options...
sircolla Posted October 30, 2010 Share Posted October 30, 2010 thanks for your reply i have already done it.Once again Thank you Link to comment Share on other sites More sharing options...
t7E4n5L1 Posted November 2, 2010 Share Posted November 2, 2010 I'm able to do what razaro suggested but I need that the page switches to a different language when the user click on the country flag. So 'newpage.php?id_lang=1' and 'newpage.php?id_lang=2' load the right translation of that page. Could you help me? Link to comment Share on other sites More sharing options...
razaro Posted November 2, 2010 Share Posted November 2, 2010 I don't know how you page looks like but for every text you display and want to be able to translate you need to use function l .If you have php file $this->l('Some text') and in tpl file {l s='Some text' } And use translate tool in back office. That should be enough so when you change language text will change too. Link to comment Share on other sites More sharing options...
t7E4n5L1 Posted November 2, 2010 Share Posted November 2, 2010 Somehow, using {l s='Some text' } in my tpl file renders the code (it's a table with js animation) unreadable. Is there a way to just redirect to a different page based on language selection? Link to comment Share on other sites More sharing options...
razaro Posted November 2, 2010 Share Posted November 2, 2010 Try to add this code include(dirname(__FILE__).'/init.php'); So page looks like <?php include(dirname(__FILE__).'/config/config.inc.php'); include(dirname(__FILE__).'/init.php'); include(dirname(__FILE__).'/header.php'); $smarty->display(_PS_THEME_DIR_.'newpage.tpl'); include(dirname(__FILE__).'/footer.php'); ?> 1 Link to comment Share on other sites More sharing options...
t7E4n5L1 Posted November 2, 2010 Share Posted November 2, 2010 My .php page already has this code in it $smarty->display(_PS_THEME_DIR_.'newpage.tpl'); I think the problem is in inserting the js into the header [removed][removed] [removed][removed] I'm not sure where this goes to be read. This is what my header.tpl looks like. > <html > <head> <title>{$meta_title|escape:'htmlall':'UTF-8'}</title> {if isset($meta_description) AND $meta_description} <meta name="description" content="{$meta_description|escape:html:'UTF-8'}" /> {/if} {if isset($meta_keywords) AND $meta_keywords} <meta name="keywords" content="{$meta_keywords|escape:html:'UTF-8'}" /> {/if} <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" /> <meta name="generator" content="PrestaShop" /> <meta name="robots" content="{if isset($nobots)}no{/if}index,follow" /> <link rel="icon" type="image/vnd.microsoft.icon" href="{$img_ps_dir}favicon.ico" /> <link rel="shortcut icon" type="image/x-icon" href="{$img_ps_dir}favicon.ico" /> {if isset($css_files)} {foreach from=$css_files key=css_uri item=media} <link href="{$css_uri}" rel="stylesheet" type="text/css" media="{$media}" /> {/foreach} {/if} [removed][removed] [removed] var baseDir = '{$content_dir}'; var static_token = '{$static_token}'; var token = '{$token}'; var priceDisplayPrecision = {$priceDisplayPrecision*$currency->decimals}; var roundMode = {$roundMode}; [removed] [removed][removed] [removed][removed] [removed][removed] {if isset($js_files)} {foreach from=$js_files item=js_uri} [removed][removed] {/foreach} {/if} {$HOOK_HEADER} </head> <body {if $page_name}id="{$page_name|escape:'htmlall':'UTF-8'}"{/if}> {if !$content_only} </pre> <ul>{l s='This shop requires JavaScript to run correctly. Please activate JavaScript in your browser.'}</ul> <br><div> <!-- Header --> {$HOOK_TOP} <!-- Center --> {/if} < Link to comment Share on other sites More sharing options...
razaro Posted November 2, 2010 Share Posted November 2, 2010 Could you zip relevant files (newpage tpl header tpl ..) and attach it to your post?If you use some custom js code surround it with {literal} .....{/literal} Also to turn debug mode on change in config/config.inc.php /* Debug only */ @ini_set('display_errors', 'on'); to help you find any errors you might have. Link to comment Share on other sites More sharing options...
t7E4n5L1 Posted November 3, 2010 Share Posted November 3, 2010 Basically, this is what I'm trying to implement in the newpage.tplhttp://css-tricks.com/examples/InfoGrid/I'm currently loading the page with an iframe. It works but I'd like something smoother.Whenever I try to call a javascript file, it seems to break the js for the whole page so I must be doing it wrong or putting it in the wrong location. Link to comment Share on other sites More sharing options...
herbalpazar Posted May 13, 2011 Share Posted May 13, 2011 Hi, I'm using the theme of healthy. TemplateMonster 32552, newpage.tpl and newpage.php files installed. But another process to create a new page than I do myself? note: the theme to activate it, I am installing dump.sql file. Link to comment Share on other sites More sharing options...
devilsown Posted November 11, 2011 Share Posted November 11, 2011 I am trying to add some js to this test file. I know i can put. <script language="javascript" src="testjsfile.js"> </script> But how would i include it so CCC will include it? in a modual i know i would do it this way. public function hookHeader($params) { Tools::addJS(($this->_path).'testjsfile.js'); } Link to comment Share on other sites More sharing options...
razaro Posted November 12, 2011 Share Posted November 12, 2011 (edited) One way to create new custom page in version 1.4.x is : 1.Create new controller for custom page. NewPageController.php <?php class NewPageControllerCore extends FrontController { public $php_self = 'new-page.php'; public function setMedia() { parent::setMedia(); Tools::addCSS(_THEME_CSS_DIR_.'new-page.css'); Tools::addJS(_THEME_JS_DIR_.'new-page.js'); } public function displayContent() { parent::displayContent(); self::$smarty->display(_PS_THEME_DIR_.'new-page.tpl'); } } NewPageController.php should be placed in controllers folder. In function setMedia() js ad css files are called from theme directory js and css folders for example, but here also can be used _PS_CSS_DIR_ and _PS_JS_DIR_ for calling files from root js and css directories. 2.Create new custom page new-page.php <?php require(dirname(__FILE__).'/config/config.inc.php'); ControllerFactory::getController('NewPageController')->run(); new-page.php should be placed in root directory (with the rest of php files) 3.Create tpl file for new page new-page.tpl {capture name=path}{l s='NewPage'}{/capture} {include file="$tpl_dir./breadcrumb.tpl"} <h1>{l s='Custom new page'}</h1> new-page.tpl should be placed in theme folder. And that is not too hard, right :-) And replace NewPage and new-page with page name you want. Just follow class NewPageControllerCore -> getController('NewPageController'), new-page.php -> new-page.tpl. One more thing do is in Back Office > Preferences > SEO & URLs , click on Add new, select custom new page (new-page.php) and fill rest of data and regenerate .htaccess file. Then instead going to website.com/new-page.php for example following could be used website.com/custom-new-page . Edited June 26, 2012 by razaro (see edit history) 11 Link to comment Share on other sites More sharing options...
benconnekt Posted February 14, 2012 Share Posted February 14, 2012 Hi razaro, Thanks for the guide, I have followed the instructions and was able to create a new page. However, the content I entered from the tpl file is not displayed. Also I will like to be able to edit the content from back office Link to comment Share on other sites More sharing options...
environs Posted February 15, 2012 Share Posted February 15, 2012 Sure it is a useful guide, Although followed the steps here I created a new page, but the content from the tpl file is not displayed. Link to comment Share on other sites More sharing options...
sixthmind Posted March 6, 2012 Share Posted March 6, 2012 Thanks so much. It works great for me, but what does it mean: {capture name=path}{l s='NewPage'}{/capture} Link to comment Share on other sites More sharing options...
sixthmind Posted March 6, 2012 Share Posted March 6, 2012 actually for some reason, when I try to add additional content, it doesn't show it. I wonder why? Link to comment Share on other sites More sharing options...
razaro Posted March 6, 2012 Share Posted March 6, 2012 Thanks so much. It works great for me, but what does it mean: {capture name=path}{l s='NewPage'}{/capture} It is for breadcrumbs. actually for some reason, when I try to add additional content, it doesn't show it. I wonder why? When editing tpl files Force Compile option needs to be set to ON, in Back office > Preferences > Performance Link to comment Share on other sites More sharing options...
sixthmind Posted March 6, 2012 Share Posted March 6, 2012 Thanks razaro for so quick reply! Force Compile option it is ON on my system and cache is disabled. Link to comment Share on other sites More sharing options...
sixthmind Posted March 6, 2012 Share Posted March 6, 2012 Never mind, for some reason it IS working now. Thanks for your help! Link to comment Share on other sites More sharing options...
bafke Posted June 5, 2012 Share Posted June 5, 2012 Hm I have the problem where nothing shows, any idea what that could be? Link to comment Share on other sites More sharing options...
Mike Kranzler Posted June 5, 2012 Share Posted June 5, 2012 Hm I have the problem where nothing shows, any idea what that could be? Hi bafke, As mentioned above, please ensure that you have Force Compile turned on and Cache turned off in your Back Office under Preferences > Performance, and also be sure to clear your browser's cache. I hope this helps. -Mike Link to comment Share on other sites More sharing options...
bafke Posted June 5, 2012 Share Posted June 5, 2012 Hi bafke, As mentioned above, please ensure that you have Force Compile turned on and Cache turned off in your Back Office under Preferences > Performance, and also be sure to clear your browser's cache. I hope this helps. -Mike Ah yes that I had, the problem tho was a typo in the controller file Link to comment Share on other sites More sharing options...
Mike Kranzler Posted June 5, 2012 Share Posted June 5, 2012 Ah yes that I had, the problem tho was a typo in the controller file Great, thanks for the update! -Mike 1 Link to comment Share on other sites More sharing options...
sannie Posted June 25, 2012 Share Posted June 25, 2012 Hi, I created a new custom page using the method as described below by razaro. Everything works, except the Page Title doesn't appear at the top of the browserpage. Even when I copy the exact new-page example, the Page Title doesn't work. I change the page title in Backoffice - Preferences - SEO & Urls and have regenerated the .htaccess file. In the past, I've created custom pages by only generating a .php and .tpl file (http://www.prestashop.com/forums/topic/49131-how-to-edit-the-html-source-of-a-cms-generated-page/) which worked fine too, but again, I never managed to be able to change the page title. Am running Prestashop 1.4.4.1. I'm struggling with this for quite some time already, any advice or ideas are highly appreciated! Thanks One way to create new custom page in version 1.4.x is : 1.Create new controller for custom page. NewPageController.php <?php class NewPageControllerCore extends FrontController { public function setMedia() { parent::setMedia(); Tools::addCSS(_THEME_CSS_DIR_.'new-page.css'); Tools::addJS(_THEME_JS_DIR_.'new-page.js'); } public function displayContent() { parent::displayContent(); self::$smarty->display(_PS_THEME_DIR_.'new-page.tpl'); } } NewPageController.php should be placed in controllers folder. In function setMedia() js ad css files are called from theme directory js and css folders for example, but here also can be used _PS_CSS_DIR_ and _PS_JS_DIR_ for calling files from root js and css directories. 2.Create new custom page new-page.php <?php require(dirname(__FILE__).'/config/config.inc.php'); ControllerFactory::getController('NewPageController')->run(); new-page.php should be placed in root directory (with the rest of php files) 3.Create tpl file for new page new-page.tpl {capture name=path}{l s='NewPage'}{/capture} {include file="$tpl_dir./breadcrumb.tpl"} <h1>{l s='Custom new page'}</h1> new-page.tpl should be placed in theme folder. And that is not too hard, right :-) And replace NewPage and new-page with page name you want. Just follow class NewPageControllerCore -> getController('NewPageController'), new-page.php -> new-page.tpl. One more thing do is in Back Office > Preferences > SEO & URLs , click on Add new, select custom new page (new-page.php) and fill rest of data and regenerate .htaccess file. Then instead going to website.com/new-page.php for example following could be used website.com/custom-new-page . Link to comment Share on other sites More sharing options...
sixthmind Posted June 26, 2012 Share Posted June 26, 2012 try adding public $php_self = 'newpage.php'; above function setMedia() in NewPageController.php Link to comment Share on other sites More sharing options...
sannie Posted June 26, 2012 Share Posted June 26, 2012 hi sixthmind, it finally works now! just fab, thanks so much! ! Link to comment Share on other sites More sharing options...
razaro Posted June 26, 2012 Share Posted June 26, 2012 try adding public $php_self = 'newpage.php'; above function setMedia() in NewPageController.php Yes that line is missing, thanks sixthmind. Link to comment Share on other sites More sharing options...
Wajiha Posted July 13, 2012 Share Posted July 13, 2012 Hi, I have followed the same steps but I also have same problem that content is not displaying on frontend. Can anyone please help me out for this? Link to comment Share on other sites More sharing options...
Wajiha Posted July 14, 2012 Share Posted July 14, 2012 Hi, can anyone tell me how can I make custom page SEO friendly, actually its a little complicated then what has been discussed so far on this topic. What i want is on a custom page I want to display testimonials which are managed through a module and on the same page user can add testimonials using a form. What I have done so far is I am able to show testimonials which are added and form also the only problem i am facing as website is using SEO friendly url so when i try to add anything using that form it shows 404 error because I have addressed a php file in action of the form. How can I solve this option is there any better option to do so? Thanks, Wajiha Link to comment Share on other sites More sharing options...
cyberespia Posted July 31, 2012 Share Posted July 31, 2012 thank you! Link to comment Share on other sites More sharing options...
tudorached Posted August 17, 2012 Share Posted August 17, 2012 (edited) I did all the above but I still get a 404 error 500 Internal Error when I try to acces my php file. Can you help me? I run on Prestashop 1.4.8.2. Anyone has any ideas? Thanks in advance... Edited August 17, 2012 by tudorached (see edit history) Link to comment Share on other sites More sharing options...
razaro Posted August 17, 2012 Share Posted August 17, 2012 Can you send me your files/code by PM and do you have link to your website ? Link to comment Share on other sites More sharing options...
tudorached Posted August 17, 2012 Share Posted August 17, 2012 (edited) Can you send me your files/code by PM and do you have link to your website ? I can tell you my process: 1.I've added new-page.php in the main folder, near the rest of the php files <?php require(dirname(__FILE__).'/config/config.inc.php'); ControllerFactory::getController('NewPageController')->run(); 2. I've added NewPageController.php in the controllers folder, near the rest of controllers <?php class NewPageControllerCore extends FrontController { public $php_self = 'new-page.php'; public function setMedia() { parent::setMedia(); Tools::addCSS(_THEME_CSS_DIR_.'new-page.css'); Tools::addJS(_THEME_JS_DIR_.'new-page.js'); } public function displayContent() { parent::displayContent(); self::$smarty->display(_PS_THEME_DIR_.'new-page.tpl'); } } 3. I've added new-page.tpl in my theme's folder {capture name=path}{l s='NewPage'}{/capture} {include file="$tpl_dir./breadcrumb.tpl"} <h1>{l s='Custom new page'}</h1> 4. In my admin interface Prefferences -> SEO&URLs I've added new-page.php 5. I've generated a new .htaccess in admin interface Tools -> Generators 6. I try to access the new-page by using the address http://www.mydomain.com/new-page.php or http://www.mydomain.com/new-page and i get 500 Internal Error Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, [email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. I've looked in the .htaccess file to see if it's updated and there I can find the line RewriteRule ^new-page$ /new-page.php [QSA,L] Thank you for helping me. ps: I've also checked in Back office > Preferences > Performance Force Compile is enabled and Cache disabled. Edited August 17, 2012 by tudorached (see edit history) Link to comment Share on other sites More sharing options...
razaro Posted August 17, 2012 Share Posted August 17, 2012 Code seems fine. Could you try to enable debug mode and/or dev mode to see if it will display some specific error. config.inc.php /* Debug only */ @ini_set('display_errors', 'on'); defines.inc.php define('_PS_MODE_DEV_', true); And also in your hosing Cpanel check apache error log Link to comment Share on other sites More sharing options...
tudorached Posted August 17, 2012 Share Posted August 17, 2012 (edited) And also in your hosing Cpanel check apache error log Thanks to your advice I've solved it. After looking in the apache error log I've found the error SoftException in Application.cpp:256: File "....../new-page.php" is writeable by group . Somehow the php file had all the writing permissions checked and the server didn't allow it to be accessed. I've left enabled just the user writing access and now it works just fine. Thank you again. Edited August 17, 2012 by tudorached (see edit history) Link to comment Share on other sites More sharing options...
glennlawre Posted September 19, 2012 Share Posted September 19, 2012 One way to create new custom page in version 1.4.x is : 1.Create new controller for custom page. NewPageController.php <?php class NewPageControllerCore extends FrontController { public $php_self = 'new-page.php'; public function setMedia() { parent::setMedia(); Tools::addCSS(_THEME_CSS_DIR_.'new-page.css'); Tools::addJS(_THEME_JS_DIR_.'new-page.js'); } public function displayContent() { parent::displayContent(); self::$smarty->display(_PS_THEME_DIR_.'new-page.tpl'); } } NewPageController.php should be placed in controllers folder. In function setMedia() js ad css files are called from theme directory js and css folders for example, but here also can be used _PS_CSS_DIR_ and _PS_JS_DIR_ for calling files from root js and css directories. 2.Create new custom page new-page.php <?php require(dirname(__FILE__).'/config/config.inc.php'); ControllerFactory::getController('NewPageController')->run(); new-page.php should be placed in root directory (with the rest of php files) 3.Create tpl file for new page new-page.tpl {capture name=path}{l s='NewPage'}{/capture} {include file="$tpl_dir./breadcrumb.tpl"} <h1>{l s='Custom new page'}</h1> new-page.tpl should be placed in theme folder. And that is not too hard, right :-) And replace NewPage and new-page with page name you want. Just follow class NewPageControllerCore -> getController('NewPageController'), new-page.php -> new-page.tpl. One more thing do is in Back Office > Preferences > SEO & URLs , click on Add new, select custom new page (new-page.php) and fill rest of data and regenerate .htaccess file. Then instead going to website.com/new-page.php for example following could be used website.com/custom-new-page . This worked great for me thanks... Can you please advise how it is possible to add multiple custom pages? Can you add detail to the same NewPageController.php to call additional custom pages, or do you need a seperate NewPageController.php for each custom page? Thanks... Link to comment Share on other sites More sharing options...
razaro Posted September 20, 2012 Share Posted September 20, 2012 This way is meant to be be used when you need to make one custom page with it's own css and js files. For multiple custom pages you will need to repeat whole thing for each page which is not too good. You should try to use CMS pages feature of Prestashop if you can. If not there is option to override CMSController or to make custom module to match you needs. Link to comment Share on other sites More sharing options...
glennlawre Posted September 20, 2012 Share Posted September 20, 2012 I did try to replicate what I did for a second page, but this did not work for me. I did the following: NewPageController2.php - I named this "NewPageController2" <?php class NewPageControllerCore extends FrontController { public $php_self = 'new-page2.php'; public function setMedia() { parent::setMedia(); Tools::addCSS(_THEME_CSS_DIR_.'new-page.css'); Tools::addJS(_THEME_JS_DIR_.'new-page.js'); } public function displayContent() { parent::displayContent(); self::$smarty->display(_PS_THEME_DIR_.'new-page2.tpl'); } } NewPageController2.php was placed in controllers folder. I used the same .css & .js for this page. 2.Create new custom page new-page2.php <?php require(dirname(__FILE__).'/config/config.inc.php'); ControllerFactory::getController('NewPageController2')->run(); new-page2.php was placed in root directory (with the rest of php files) 3.Create tpl file for new page new-page2.tpl {capture name=path}{l s='NewPage2'}{/capture} {include file="$tpl_dir./breadcrumb.tpl"} <h1>{l s='Custom new page'}</h1> new-page2.tpl was placed in the theme directory. Can you tell me where I am going wrong? I really only need two of these custom pages so this is probably the easiest way to do it. CMS page won't really work with the way I want to controll the layout/functions of the page etc. Thanks... Link to comment Share on other sites More sharing options...
razaro Posted September 20, 2012 Share Posted September 20, 2012 class NewPageControllerCore extends FrontController Try to change this to class NewPageController2Core extends FrontController 1 Link to comment Share on other sites More sharing options...
glennlawre Posted September 20, 2012 Share Posted September 20, 2012 That done Cheers for your help... Link to comment Share on other sites More sharing options...
radovan Posted October 18, 2012 Share Posted October 18, 2012 Hi please you have a solution for a prestashop 1.5 ? how i can add the custom page in the 1.5 ? thank you Link to comment Share on other sites More sharing options...
radovan Posted October 22, 2012 Share Posted October 22, 2012 ok i find the solution but i have a problem with redirection its meen iam still redirect to index.php?controller=page.php i added the rules in backoffice but without any result .. thank you Link to comment Share on other sites More sharing options...
razaro Posted October 24, 2012 Share Posted October 24, 2012 @radovan had trouble with that also and I think problem is in name "new-page" don't work but "newpage" do. Reason is maybe somewhere in code controller name is searched using regular expression but "-" is missed. So here is complete code to adding new, custom page to version 1.5. 1.Create new controller for custom page. It should be placed in root directory > controllers/front folder. NewPageController.php <?php class NewPageControllerCore extends FrontController { public $php_self = 'newpage'; public function setMedia() { parent::setMedia(); $this->addCSS(_THEME_CSS_DIR_.'newpage.css'); $this->addJS(_THEME_JS_DIR_.'newpage.js'); } public function initContent() { parent::initContent(); $this->setTemplate(_PS_THEME_DIR_.'newpage.tpl'); } } Note that js and css file are added just for an example. If not needed whole function setMedia() could be left out. 2.Create new custom page in root directory. newpage.php <?php /** * This file will be removed in 1.6 * You have to use index.php?controller=page_name instead of this page * * @deprecated 1.5.0 */ require(dirname(__FILE__).'/config/config.inc.php'); Tools::displayFileAsDeprecated(); Tools::redirect('index.php?controller=newpage'.($_REQUEST ? '&'.http_build_query($_REQUEST, '', '&') : ''), __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently'); 3.Create tpl file for new page and place it in theme folder. newpage.tpl {capture name=path}{l s='CustomNewPage'}{/capture} {include file="$tpl_dir./breadcrumb.tpl"} <h1>{l s='Custom new page'}</h1> 4. Last step is to add new page in Preferences > SEO & URLs 6 Link to comment Share on other sites More sharing options...
radovan Posted October 26, 2012 Share Posted October 26, 2012 its work nice thank you ! Link to comment Share on other sites More sharing options...
infoseek Posted November 27, 2012 Share Posted November 27, 2012 (edited) @radovan had trouble with that also and I think problem is in name "new-page" don't work but "newpage" do. Reason is maybe somewhere in code controller name is searched using regular expression but "-" is missed. So here is complete code to adding new, custom page to version 1.5. 1.Create new controller for custom page. It should be placed in root directory > controllers/front folder. NewPageController.php <?php class NewPageControllerCore extends FrontController { public $php_self = 'newpage'; public function setMedia() { parent::setMedia(); $this->addCSS(_THEME_CSS_DIR_.'newpage.css'); $this->addJS(_THEME_JS_DIR_.'newpage.js'); } public function initContent() { parent::initContent(); $this->setTemplate(_PS_THEME_DIR_.'newpage.tpl'); } } Note that js and css file are added just for an example. If not needed whole function setMedia() could be left out. 2.Create new custom page in root directory. newpage.php <?php /** * This file will be removed in 1.6 * You have to use index.php?controller=page_name instead of this page * * @deprecated 1.5.0 */ require(dirname(__FILE__).'/config/config.inc.php'); Tools::displayFileAsDeprecated(); Tools::redirect('index.php?controller=newpage'.($_REQUEST ? '&'.http_build_query($_REQUEST, '', '&') : ''), __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently'); 3.Create tpl file for new page and place it in theme folder. newpage.tpl {capture name=path}{l s='CustomNewPage'}{/capture} {include file="$tpl_dir./breadcrumb.tpl"} <h1>{l s='Custom new page'}</h1> 4. Last step is to add new page in Preferences > SEO & URLs thanks,this is exactly what I want! Edited November 27, 2012 by infoseek (see edit history) Link to comment Share on other sites More sharing options...
Mr S Posted February 26, 2013 Share Posted February 26, 2013 Thanks @razaro just what i was looking for. And you don't need to Create a new custom page in root directory newpage.php if you need seo urls for your newpage like: newpage/newnewpage override the Dispatcher.php 'newpage_rule' => array( 'controller' => 'newpage', 'rule' => 'newpage{/:info}', 'keywords' => array( 'info' => array('regexp' => '[_a-zA-Z0-9-\pL]*', 'param' => info'), ), ), 1 Link to comment Share on other sites More sharing options...
devilsown Posted April 3, 2013 Share Posted April 3, 2013 Anyone got a way how to do this on 1.5.4 ? Link to comment Share on other sites More sharing options...
glennlawre Posted April 4, 2013 Share Posted April 4, 2013 (edited) I have successfully created a custom page using your instructions, but now I am trying to create a 2nd custom page as I need two. You actually advised me on how to do this in v1.4 here However I cannot get this to work on 1.5.4. Here are the steps I have followed: Can you please advise? Thanks in advance... 1.Create new controller for custom page. It should be placed in root directory > controllers/front folder. NewPageController2.php <?php class NewPageController2Core extends FrontController { public $php_self = 'newpage'; public function setMedia() { parent::setMedia(); $this->addCSS(_THEME_CSS_DIR_.'newpage.css'); $this->addJS(_THEME_JS_DIR_.'newpage.js'); } public function initContent() { parent::initContent(); $this->setTemplate(_PS_THEME_DIR_.'newpage2.tpl'); } } Note that js and css file are added just for an example. If not needed whole function setMedia() could be left out. 2.Create new custom page in root directory. newpage2.php <?php /** * This file will be removed in 1.6 * You have to use index.php?controller=page_name instead of this page * * @deprecated 1.5.0 */ require(dirname(__FILE__).'/config/config.inc.php'); Tools::displayFileAsDeprecated(); Tools::redirect('index.php?controller=newpage2'.($_REQUEST ? '&'.http_build_query($_REQUEST, '', '&') : ''), __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently'); 3.Create tpl file for new page and place it in theme folder. newpage2.tpl {capture name=path}{l s='CustomNewPage'}{/capture} {include file="$tpl_dir./breadcrumb.tpl"} <h1>{l s='Custom new page'}</h1> 4. Last step is to add new page in Preferences > SEO & URLs Edited April 4, 2013 by glennlawre (see edit history) Link to comment Share on other sites More sharing options...
razaro Posted April 5, 2013 Share Posted April 5, 2013 @glennlawre Change class NewPageController2Core extends FrontController to class NewPage2ControllerCore extends FrontController So class name must end with ControllerCore. I have tested this on fresh 1.5.4.0 and it works. 1 Link to comment Share on other sites More sharing options...
glennlawre Posted April 5, 2013 Share Posted April 5, 2013 (edited) @razaro Change class NewPageController2Core extends FrontController to class NewPage2ControllerCore extends FrontController So class name must end with ControllerCore. I have tested this on fresh 1.5.4.0 and it works. Worked great, thanks again...! And I am on PS 1.5.4.0 One quick thing for anyone else that may get stuck on this, you need to make sure you name the "NewPageController.php" page the same as what you put in the string, e.g. if you have "NewPage2ControllerCore" in your string for an additional page, you also need to name the controller page "NewPage2ControllerCore.php" and place in the controllers/front directory. But I'm sure most people will already know this... Edited April 5, 2013 by glennlawre (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...certificatcadou. 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 = certificatcadou Still no luck!! Can you advise what could be wrong? Robert Edit: 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...
razaro Posted May 30, 2013 Share Posted May 30, 2013 <?php class FrontController extends FrontControllerCore { public function init() { parent::init(); $this--->context->smarty->assign('currentController', get_class($this)); } } Here you have $this--->context instead of $this->context . Also you can move $this->context->smarty->assign('currentController', get_class($this)); to your CertificatCadouControllerCore init function. 1 Link to comment Share on other sites More sharing options...
Rhobur Posted May 30, 2013 Share Posted May 30, 2013 <?php class FrontController extends FrontControllerCore { public function init() { parent::init(); $this--->context->smarty->assign('currentController', get_class($this)); } } Here you have $this--->context instead of $this->context . Also you can move $this->context->smarty->assign('currentController', get_class($this)); to your CertificatCadouControllerCore init function. Thanks razaro for trying to help! The $this--->context was a small typo actually it is $this-->context sorry for misleading you. But, I have moved $this->context->smarty->assign('currentController', get_class($this)); to CertificatCadouControllerCore init function which looks like this now: [/color] [color=#000000]class CertificatCadouControllerCore extends FrontController { public $php_self = 'certificatcadou';[/color] [color=#000000]public function initContent() { parent::initContent(); $this->setTemplate(_PS_THEME_DIR_.'certificatcadou.tpl'); $this->context->smarty->assign('currentController', get_class($this)); } } Still, no luck, I can't figure it out for my life! Link to comment Share on other sites More sharing options...
razaro Posted May 30, 2013 Share Posted May 30, 2013 Try to delete class_index.php in root cache folder. 1 Link to comment Share on other sites More sharing options...
Rhobur Posted May 31, 2013 Share Posted May 31, 2013 Try to delete class_index.php in root cache folder. Class class_index.php deleted and then re generated. Same error though, first a server error with an interminable string then at reload, Page not found. See here, http://www.caprice-s...certificatcadou Thanks for patience! Link to comment Share on other sites More sharing options...
razaro Posted May 31, 2013 Share Posted May 31, 2013 OK I tried on local server and found 2 issues. Here are codes for files. CertificatCadouController.php <?php class CertificatCadouControllerCore extends FrontController { public $php_self = 'certificatcadou'; public function initContent() { parent::initContent(); $this->context->smarty->assign('currentController', get_class($this)); $this->setTemplate(_PS_THEME_DIR_.'certificatcadou.tpl'); } } certificatcadou.php (was missing <?php tag at beginning ) <?php 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'); certificatcadou.tpl (wrong variable name used) {include file="$tpl_dir./breadcrumb.tpl"} {include file="$tpl_dir./errors.tpl"} <h1>Testpage</h1> controller: {$currentController} In controller variable currentController is assigned so that is used in tpl file. This should work for you now. 1 Link to comment Share on other sites More sharing options...
Rhobur Posted May 31, 2013 Share Posted May 31, 2013 OK I tried on local server and found 2 issues. Here are codes for files. CertificatCadouController.php <?php class CertificatCadouControllerCore extends FrontController { public $php_self = 'certificatcadou'; public function initContent() { parent::initContent(); $this->context->smarty->assign('currentController', get_class($this)); $this->setTemplate(_PS_THEME_DIR_.'certificatcadou.tpl'); } } certificatcadou.php (was missing <?php tag at beginning ) <?php 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'); certificatcadou.tpl (wrong variable name used) {include file="$tpl_dir./breadcrumb.tpl"} {include file="$tpl_dir./errors.tpl"} <h1>Testpage</h1> controller: {$currentController} In controller variable currentController is assigned so that is used in tpl file. This should work for you now. Changed all files as suggested, deleted cache, deleted class_index.php and now I have a redirect loop error at http://www.caprice-shop.ro/index.php?controller=certificatcadou I have to check it further. Since it works for you it must be a problem with my configuration somehow. Thank you for your patience! Link to comment Share on other sites More sharing options...
El Patron Posted July 13, 2013 Share Posted July 13, 2013 for 1.5, here is a great (best in my opinion) http://nemops.com/creating-new-pages-in-prestashop/ thanks nemo1 Link to comment Share on other sites More sharing options...
Dallerdkj Posted November 23, 2013 Share Posted November 23, 2013 I struggled with this, but when i deleted class_index.php in cache folder and regenerated, everything worked! Thanks 1 Link to comment Share on other sites More sharing options...
JDStanley Posted December 5, 2013 Share Posted December 5, 2013 (edited) Will this sample code by razaro work on latest prestashop 1.5.6 this sample at http://nemops.com/creating-new-pages-in-prestashop/ gets installed. But when I try to configure, it throws error. Also, the CMS module did not help me to place a flash object in the page. Any help will be greatly appreciated Regards, Stanley Edited December 5, 2013 by JDStanley (see edit history) Link to comment Share on other sites More sharing options...
thenine Posted January 7, 2014 Share Posted January 7, 2014 This method works on 1.5.6.1 but you need to remember to delete "class_index.php" in root/cache folder after doing this. Thanks Razaro! @radovan had trouble with that also and I think problem is in name "new-page" don't work but "newpage" do. Reason is maybe somewhere in code controller name is searched using regular expression but "-" is missed.So here is complete code to adding new, custom page to version 1.5.1.Create new controller for custom page. It should be placed in root directory > controllers/front folder.NewPageController.php <?php class NewPageControllerCore extends FrontController { public $php_self = 'newpage'; public function setMedia() { parent::setMedia(); $this->addCSS(_THEME_CSS_DIR_.'newpage.css'); $this->addJS(_THEME_JS_DIR_.'newpage.js'); } public function initContent() { parent::initContent(); $this->setTemplate(_PS_THEME_DIR_.'newpage.tpl'); } } Note that js and css file are added just for an example. If not needed whole function setMedia() could be left out.2.Create new custom page in root directory.newpage.php <?php /** * This file will be removed in 1.6 * You have to use index.php?controller=page_name instead of this page * * @deprecated 1.5.0 */ require(dirname(__FILE__).'/config/config.inc.php'); Tools::displayFileAsDeprecated(); Tools::redirect('index.php?controller=newpage'.($_REQUEST ? '&'.http_build_query($_REQUEST, '', '&') : ''), __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently'); 3.Create tpl file for new page and place it in theme folder.newpage.tpl {capture name=path}{l s='CustomNewPage'}{/capture} {include file="$tpl_dir./breadcrumb.tpl"} <h1>{l s='Custom new page'}</h1> 4. Last step is to add new page in Preferences > SEO & URLscustomnewpage.PNG Link to comment Share on other sites More sharing options...
NoMessDrainPlug Posted February 13, 2014 Share Posted February 13, 2014 This worked great and only took me 2 tries to get it right! Thanks for the tutorial! Is there an easy way to remove areas I don't want from my new page? Example: I want to remove the header, footer, breadcrumbs, right column and main body, leaving only the left column. Link to comment Share on other sites More sharing options...
alirezahonarfar Posted July 29, 2014 Share Posted July 29, 2014 Hi every body I succeed to add new page to my web site, good for me!, but I have a primary question! Where I can add some PhP codes ( as my codes attached) to this new page?? my new page: http://barhemmat.ir/new-page.php my codes attached and works as : http://barhemmat.ir/Payment1.php my codes.php Link to comment Share on other sites More sharing options...
vekia Posted July 30, 2014 Share Posted July 30, 2014 what is your prestashop version? Link to comment Share on other sites More sharing options...
alirezahonarfar Posted August 10, 2014 Share Posted August 10, 2014 what is your prestashop version? my PS version is 1.4.9.0. I was happy by using <iframe> in CMS pages and every thing was good until the security team of bank hint me to do not use payment codes in <iframe> tag. Link to comment Share on other sites More sharing options...
vekia Posted August 11, 2014 Share Posted August 11, 2014 how you created this new page ? you have to include your php code there (i bet that it's a php file) Link to comment Share on other sites More sharing options...
alirezahonarfar Posted August 11, 2014 Share Posted August 11, 2014 how you created this new page ? you have to include your php code there (i bet that it's a php file) In advance thanks for your consideration. actually I followed the 4 step mentioned in this topic(1.Create new controller for custom page2. ....). I tried to add my codes to controller.php but no results come true. I think my codes have some problem because as u can see it is a combination of html and php together. Link to comment Share on other sites More sharing options...
durangodave Posted October 6, 2014 Share Posted October 6, 2014 (edited) not working for me in 1.6 code mission.php in root <?php require(dirname(__FILE__).'/config/config.inc.php'); Tools::displayFileAsDeprecated(); Tools::redirect('index.php?controller=mission'.($_REQUEST ? '&'.http_build_query($_REQUEST, '', '&') : ''), __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently'); controllers MissionPageController.php <?php class MissionControllerCore extends FrontController { public $php_self = 'mission'; public function initContent() { parent::initContent(); $this->context->smarty->assign('mission', get_class($this)); $this->setTemplate(_PS_THEME_DIR_.'mission.tpl'); } } and tpl file mission.tpl in themes folder include file="$tpl_dir./breadcrumb.tpl"} {include file="$tpl_dir./errors.tpl"} <h1>Mission</h1> controller: {$currentController} and then preferences -> SEO URL see image attached Edited October 6, 2014 by durangodave (see edit history) Link to comment Share on other sites More sharing options...
razaro Posted October 6, 2014 Share Posted October 6, 2014 Try to rename MissionPageController.php to MissionController.php Link to comment Share on other sites More sharing options...
durangodave Posted October 6, 2014 Share Posted October 6, 2014 renamed and still 500 error http://www.durangodaves.com/mission Link to comment Share on other sites More sharing options...
durangodave Posted October 6, 2014 Share Posted October 6, 2014 (edited) i also just attemped the CMS way. And i can create the category in CMS no problem, but when i go to add a new page to the new category i get this, and i get this with or without tokens being enabled. and fyi dont worry about the special coding from before with the new class, i removed it cause it was not working. Edited October 6, 2014 by durangodave (see edit history) Link to comment Share on other sites More sharing options...
razaro Posted October 6, 2014 Share Posted October 6, 2014 (edited) For CMS error try this solution, from another topic http://www.prestashop.com/forums/topic/355328-solved-admin-cms-page-blank-token-error/?do=findComment&comment=1790068 But for sake of this topic, I have few things to add. Php file in root is not needed anymore, maybe for some time. So in your case mission.php is not needed. Then in mission.tpl code should be controller: {$mission} but that does not influence 404 error. You could try to clear cache in back office ( Advanced parameter > Performance). I got this Edited October 23, 2015 by razaro (see edit history) Link to comment Share on other sites More sharing options...
ferry_desantos Posted November 29, 2014 Share Posted November 29, 2014 Check this module: http://addons.prestashop.com/en/content-management/18175-ps-new-pages.html It does it. Link to comment Share on other sites More sharing options...
Rissinko Posted January 22, 2015 Share Posted January 22, 2015 Hi how add custom page to prestashop 1.6 I trying everything and the custom page working via url prestashopurlpage.xxx/new-page.php but missing in "SEO and URL > add new page " ... Link to comment Share on other sites More sharing options...
kundan1947 Posted January 28, 2015 Share Posted January 28, 2015 Hey I want to add 1-2 customize page with coding in prestashop 1.6.0.11, please give me sample file with instruction how to add that and customize that. Somethings which i need in that customize page 1) I want a full width banner. 2) I want to add offers image in 4 to 6 groups with text bar above them differentiating each kind of offers, like this i want to add 16-25 images in one page. And i want that images can be change from the back-end(Admin-Panel) time to time. 3) with common footer. Please help me Thanks in advance. Link to comment Share on other sites More sharing options...
NemoPS Posted January 28, 2015 Share Posted January 28, 2015 here: http://blog.arvixe.com/how-to-create-new-pages-in-prestashop/ Link to comment Share on other sites More sharing options...
kundan1947 Posted January 28, 2015 Share Posted January 28, 2015 As i told you I want to add following things: 1) I want a full width banner on top then.2) I want to add offers image in 4 to 6 groups with text bar above them differentiating each kind of offers, like this i want to add 16-25 images in one page. And i want that images can be change from the back-end(Admin-Panel) time to time.3) with common footer. Please explain me how to make these things on new pages in prestashop. Link to comment Share on other sites More sharing options...
razaro Posted January 28, 2015 Share Posted January 28, 2015 He did explained to you, you need to make custom module. Module controller displays new custom page, you can add images in module back office configuration page. Check out block banner module for adding full width banner at top, but limit just on that custom page. Also check homeslider module for adding images, sorting them and so on. If you are not developer you could ask in Job offers for quote. 1 Link to comment Share on other sites More sharing options...
tuk66 Posted February 9, 2015 Share Posted February 9, 2015 Create your pages as CMS and style them using CSS. It shouldn't be a big problem. Link to comment Share on other sites More sharing options...
robbinj Posted February 11, 2015 Share Posted February 11, 2015 A question, when I want to style with css it deletes the complete css when I save it? Link to comment Share on other sites More sharing options...
NemoPS Posted February 11, 2015 Share Posted February 11, 2015 Deletes the complete css? What do you mean? Link to comment Share on other sites More sharing options...
shri Posted April 10, 2015 Share Posted April 10, 2015 You could go to Back Office » Tools » CMS and click on Add new. And use some module to add it to homepage. Another way is to create for example newpage.php <?phpinclude(dirname(__FILE__).'/config/config.inc.php');include(dirname(__FILE__).'/header.php');$smarty->display(_PS_THEME_DIR_.'newpage.tpl');include(dirname(__FILE__).'/footer.php');?>and save it to main prestashiop folder and then in your theme folder create file newpage.tpl. Both files are in attachment. Thank you Razaro. that was just what i wanted. Link to comment Share on other sites More sharing options...
Ferdem Posted June 10, 2015 Share Posted June 10, 2015 I applied all of them but i cant use friendly url If i try to friendl url than i get 404 Can you help me ? Halibul.com/hali.php - it is normally Halibul.com/hali - i get 404 Link to comment Share on other sites More sharing options...
shri Posted June 11, 2015 Share Posted June 11, 2015 (edited) I applied all of them but i cant use friendly url If i try to friendl url than i get 404 Can you help me ? Halibul.com/hali.php - it is normally Halibul.com/hali - i get 404 Hi I don't see any error on these pages http://www.halibul.com/hali http://www.halibul.com/hali.php Edited June 11, 2015 by shri (see edit history) Link to comment Share on other sites More sharing options...
arpheel Posted November 6, 2016 Share Posted November 6, 2016 Good day everyone! I'm Ruel and just new to this forum. I just want to ask solution to my situation as I created a new page from CMS and I want it to appear to my footer and header of my website. My question is how can I make it appear to my footer and header of my website? Thanks in advance for all your help. GOD-speed! Link to comment Share on other sites More sharing options...
NemoPS Posted November 7, 2016 Share Posted November 7, 2016 You mean you need a link? Edit either footer or header.tpl and add {$link->getCMSLink(YOUR ID)} Link to comment Share on other sites More sharing options...
امیر Posted July 28, 2017 Share Posted July 28, 2017 i creat newpage,php and creat newpage.tpl and coppy code file prouductlist.tpl in newpage.tpl but not working url http://puzel.ir/newpage.php Link to comment Share on other sites More sharing options...
NemoPS Posted July 29, 2017 Share Posted July 29, 2017 It doesn't work like that, you should use this method: http://nemops.com/creating-new-pages-in-prestashop/#.WXx16IiGOUk Link to comment Share on other sites More sharing options...
Recommended Posts