abbood Posted May 5, 2012 Share Posted May 5, 2012 I'm currently working on making my module compatible with PS 1.5 (It works on PS 1.4.x) when I enter this: include(dirname(__FILE__).'/../../header.php'); I get this error: Warning: Function displayHeader() is deprecated in /Users/abdullahbakhach/dev/Prestashop/ps15/1.5.x/header.php on line 40 in /Users/abdullahbakhach/dev/Prestashop/ps15/1.5.x/classes/Tools.php on line 1777 Similarly, when I enter this: include(dirname(__FILE__).'/../../footer.php'); I get this error: Warning: Function displayFooter() is deprecated in/Users/abdullahbakhach/dev/Prestashop/ps15/1.5.x/footer.php on line 40 in /Users/abdullahbakhach/dev/Prestashop/ps15/1.5.x/classes/Tools.php on line 1777 I did some digging, and it seems that in ps1.5 all what header.php and footer.php do is see if the Context object has a controller object instantiated already.. if so it uses it and if not it creates one from scratch, then it calls controller->init(); : if (isset(Context::getContext()->controller)) $controller = Context::getContext()->controller; else { $controller = new FrontController(); $controller->init(); } Tools::displayFileAsDeprecated(); $controller->displayHeader(); The interesting part here is that controller->displayHeader/Footer() do exactly what I need (that's how it behaved in PS 1.4.x).. but in PS 1.5 it just says that they are deprecated yet show no alternative function or way of doing the same thing.. ideas? Link to comment Share on other sites More sharing options...
abbood Posted May 5, 2012 Author Share Posted May 5, 2012 Basically what I want to achieve is to have a link on the 'my-account' page be able to display content on an independent page that i create.. adding the link on the my-account page was simple enough.. just add content to the 'hookCustomerAccount' hook. that content is a simple title of my module with a link.. however how can i make that link go to a new page? i looked at what the other links point to.. and apparently they all point to core modules.. example: for 'my vouchers' a link takes the user to the discount controller page.. which is controllers/front/DiscountController.php.. that page displays the corresponding template etc etc.. obviously this can't be a solution for me (or any other 3rd party module developer) b/c anything outside the /modules directory is considered no-man's land for us. i guess a better title for the original post would be: how can a module developer create a stand-alone page in prestashop 1.5 Link to comment Share on other sites More sharing options...
mexique1 Posted May 16, 2012 Share Posted May 16, 2012 (edited) You can now create a controller to do this. Just check in the native modules which have a /controllers/front directory for a working example. Edited May 16, 2012 by mexique1 (see edit history) Link to comment Share on other sites More sharing options...
MEG Venture Posted January 13, 2013 Share Posted January 13, 2013 Hi Did you find a solution to this problem? I have the same error in 1.5.3.1 Link to comment Share on other sites More sharing options...
elisa_34 Posted February 16, 2013 Share Posted February 16, 2013 up, help is need too ^^ Link to comment Share on other sites More sharing options...
elisa_34 Posted February 17, 2013 Share Posted February 17, 2013 (edited) really don't get why I can't use : $controller=new FrontController(); $controller->init(); $controller->initContent(); $controller->displayFooter(); Edited February 17, 2013 by elisa_34 (see edit history) Link to comment Share on other sites More sharing options...
devilsown Posted April 4, 2013 Share Posted April 4, 2013 Any helpfull walk threw. for 1.5x on creating a new page. Link to comment Share on other sites More sharing options...
vekia Posted April 4, 2013 Share Posted April 4, 2013 @devilsown you've got troubles with creating new page? May i help? Link to comment Share on other sites More sharing options...
netplayer Posted April 9, 2013 Share Posted April 9, 2013 Ok, having same problem. On 1.5.3 i was running a custom module page using just header and footer includes in the php which does not work anymore since upgrade to 1.5.4. Now page looks completely messed up and also jquery isn't loaded on this page. Same happens after i implemented same page using a custom controller , though i am still not sure i deploy it the right way , i am working on it aided by the non-existent Prestashop documentation.. This should be a simple task to accomplish, like it is on any other framework but... Any known guideline to go along maybe? Link to comment Share on other sites More sharing options...
vekia Posted April 10, 2013 Share Posted April 10, 2013 in this case you should use front controller class and set up setmedia() function 1 Link to comment Share on other sites More sharing options...
netplayer Posted April 10, 2013 Share Posted April 10, 2013 (edited) in this case you should use front controller class and set up setmedia() function Thank you, it did work as expected.I extended ModuleFrontController, this looks like the only way to have the layout along with client scripts loading properly on a stand-alone prestashop page. Edited April 11, 2013 by netplayer (see edit history) Link to comment Share on other sites More sharing options...
webbax Posted April 17, 2013 Share Posted April 17, 2013 (edited) Bonjour, Je rencontre exactement le même problème, du coup cette version demande de revoir chaque module de paiement. Voici un exemple ci dessous de code avant puis après migration pour avoir la compatibilité avec cette nouvelle version. Exemple avec "payment.php" Avant migration /* SSL Management */ $useSSL = true; include(dirname(__FILE__).'/../../config/config.inc.php'); include(dirname(__FILE__).'/../../header.php'); include(dirname(__FILE__).'/swissbilling.php'); if (!$cookie->isLogged(true)) Tools::redirect('authentication.php?back=order.php'); $swissbilling = new Swissbilling(); echo $swissbilling->execPayment($cart); include_once(dirname(__FILE__).'/../../footer.php'); Après migration compatible Prestashop 1.5.4 /* SSL Management */ $useSSL = true; include(dirname(__FILE__).'/../../config/config.inc.php'); $controller=new FrontController(); $controller->init(); $controller->initContent(); $controller->setMedia(); $controller->displayHeader(); if (!$cookie->isLogged(true)) Tools::redirect('authentication.php?back=order.php'); include(dirname(__FILE__).'/swissbilling.php'); $swissbilling = new Swissbilling(); echo $swissbilling->execPayment($cart); $controller->displayFooter(); A mon sens on ne devrait pas voir un changement aussi brutal entre deux version du même type. De 1.4 vers 1.5 je comprends... mais là c'est déjà plus délicat. Edited April 17, 2013 by webbax (see edit history) Link to comment Share on other sites More sharing options...
pppplus Posted April 18, 2013 Share Posted April 18, 2013 Perfect ! This solution works ! I was searching why I have a problem with my module. Only one value seems to be forgotten by old method : [/themes/default/css/global.css] => all With your solution, this value is here, and page is beautiful Merci ! Link to comment Share on other sites More sharing options...
Start Online Design Posted May 8, 2013 Share Posted May 8, 2013 Thanks! Good solution, but it is temporary because begining with 1.6 the function displayHeader will be removed Link to comment Share on other sites More sharing options...
luciep Posted October 24, 2013 Share Posted October 24, 2013 Bonjour à tous ! Désolée de dépoussiérer ce post mais j'ai eu le même problème et voici la solution que j'ai trouvé : D'après moi lil faut créer un nouveau controlleur pour pouvoir afficher une nouvelle page sans les erreurs, faire une page php externe avec le header et le footer de prestashop n'est opas une bonne solution. Je vous fait un mini tuto avec un exemple un poil complexe avec un formulaire (traitement des résultats et affichage de message d'erruer et de succès) : Imaginons que l'on veuille ajouter un formulaire à Prestashop (demande de devis, de partenariat...). Il faut créer un nouveau controlleur dans le dossier /controllers/front, que l'on pourra nommer comme on le souhaite (gardez quand même Controller.php comme fin de nom de fichier), par exemple : MyNewControllerController.php. Il faudra aussi avoir un template pour l'affichage de la page (du formulaire). Le template se met dans votre dossier themes/montheme/ et dans l'idéal reprendra le nom de votre controlleur. Ici cela sera donc "mynewcontroller.tpl". Le contenu du controlleur sera du type : class MyNewControllerControllerCore extends FrontController { public $php_self = 'mynewcontroller'; public $ssl = true; // on peut ajouter des variables au besoin public $affichebon = false; public $error_form = false; public $error_mail = false; /** * Start forms process * @see FrontController::postProcess() */ public function postProcess() { if (Tools::isSubmit('submitForm')) { // gestion traitement actions à réaliser en cas de soumission du formulaire // il faut remplir les tests à faire sur vos champs de formulaire // modification des variables selon le résultat if ($jesais pasquoi = $jesaispasquoidautre) { $this->affichebon = true; $this->error_form = false; $this->error_mail = false; } else { $this->affichebon = false; $this->error_form = true; $this->error_mail = false; } } public function setMedia() { parent::setMedia(); // on peut ajouter des fichiers css et/ou js en cas de besoin $this->addCSS(_THEME_CSS_DIR_.'mycssfile.css'); $this->addJS(_THEME_JS_DIR_.'myjsfile.js'); } /** * Assign template vars related to page content * @see FrontController::initContent() */ public function initContent() { parent::initContent(); // on peut passer des variables à notre fichier tpl (variables qui peuvent être modifées dans la function postProcess $this->context->smarty->assign(array( 'affichebon' => $this->affichebon, 'error_form' => $this->error_form, 'error_mail' => $this->error_mail )); //on lance le tpl $this->setTemplate(_PS_THEME_DIR_.'mynewcontroller.tpl'); } } et le fichier de template pourra être du genre {if $affichebon} <div align='center'> <h4>{l s='Merci de votre participation'}</h4> <a href="{$base_dir}">{l s='Retour a la page d\'accueil'}</a></p> </div> {/if} {if $error_form || $error_mail} {if $error_form}<p>{l s='Vous devez remplir tous les champs obligatoires.'} <a href="javascript:history.back();">{l s='Retour au formulaire'}</a></p>{/if} {if error_mail}<p>{l s='Erreur lors de l\'envoi de l\'email.'} <a href="javascript:history.back();">{l s='Retour au formulaire'}</a></p>{/if} {else} // on affiche la page ou le formulaire <form....> [..........] </form> {/if} et là du coup on peut afficher la page avec le header et le footer sans erreur de fonctions dépréciées avec le lien suivant : index.php?controller=mynewcontroller Dans le cas d'une page toute bête, pas besoin de postProcess ni de variables dans le controller il faut juste afficher le tpl qui contiendra déjà toute les données html. j'espère avoir pu aider quelques personnes. Link to comment Share on other sites More sharing options...
vekia Posted October 24, 2013 Share Posted October 24, 2013 hello please follow rules regarding to the language, not everyone know french here 1 Link to comment Share on other sites More sharing options...
Recommended Posts