bdesprez Posted January 15, 2021 Share Posted January 15, 2021 Hi, I have some difficulties to create a module front controller. Everithing seems fine (I used another controller of my module to create this one) but I have a fatal error … Type error: Argument 1 passed to smartyClassnames() must be of the type array, null given, called in /var/www/ps-bruno/classes/Smarty/SmartyLazyRegister.php on line 83 The controller is placed in «xlpos/controllers/front/Ventesc.php»: class XlposVentescModuleFrontController extends ModuleFrontController { public $auth = true; public $guestAllowed = false; /** * @throws PrestaShopException * @throws Exception * @see FrontController::initContent() */ public function initContent() { parent::initContent(); $this->setTemplate('module:xlpos/views/templates/front/1_7_ventesc.tpl'); $this->context->smarty->assign([ 'liste_ventes' => [], 'page' => 1 ]); } } The template is placed in «xlpos/views/templates/front/1_7_ventesc.tpl» : {extends file='customer/page.tpl'} {block name='page_title'} {l s='Purchases' mod='xlpos'} {/block} {block name='page_content'} <h6>{l s='Purchases you have made on the web AND in our shops:' mod='xlpos'}</h6> {if $liste_ventes && count($liste_ventes)} <table class="table table-striped table-bordered hidden-sm-down"> <thead class="thead-default"> <tr> <th>{l s='Purchase' mod='xlpos'}</th> <th>{l s='Date' mod='xlpos'}</th> <th>{l s='Amount' mod='xlpos'}</th> <th>{l s='View purchase' mod='xlpos'}</th> </tr> </thead> <tbody> {foreach from=$liste_ventes item=vente} <tr> <td>{$vente->vcentete_type|capitalize} #{$vente->vcentete_num}</td> <td scope="row">{dateFormat date=$vente->vcentete_date full=0}</td> <td>{Tools::displayPrice($vente->vcentete_totalttc)}</td> <td class="text-sm-center"><a href="#todo"><i class="material-icons"></i></a></td> </tr> {/foreach} </tbody> </table> {else} <aside class="notifications"> <div class="container"> <article class="alert alert-warning" role="alert" data-alert="warning"> <ul> <li>{if $page === 1 } {l s='You don\'t have any purchase!' mod='xlpos'} {else} {l s='No more purchase!' mod='xlpos'} {/if}</li> </ul> </article> </div> </aside> {/if} <nav aria-label="{l s='Purchase navigation' mod='xlpos'}"> <ul class="pagination justify-content-center"> <li class="page-item {if $page === 1 }disabled{/if}"> <a class="page-link" href="{$link->getModuleLink('xlpos', 'VentesCentralisees', ['page' => $page - 1], true)|escape:'htmlall':'UTF-8'}" tabindex="-1" {if $page === 1 }aria-disabled="true"{/if}>{l s='Newer' mod='xlpos'}</a> </li> <li class="page-item">{$page}</li> <li class="page-item {if count($liste_ventes) === 0 }disabled{/if}"> <a class="page-link" href="{$link->getModuleLink('xlpos', 'VentesCentralisees', ['page' => $page + 1], true)|escape:'htmlall':'UTF-8'}" {if count($liste_ventes) === 0 }aria-disabled="true"{/if}>{l s='Older' mod='xlpos'}</a> </li> </ul> </nav> {/block} My module listen the hook «displayCustomerAccount» and add 2 buttons : <!-- Module xlpos loyalty --> <a class="col-lg-4 col-md-6 col-sm-6 col-xs-12" id="xlpos-loyalty-link" href="{$link->getModuleLink('xlpos', 'Loyalty', ['id_externe' => $id_externe, 'identfidelite' => $identfidelite], true)|escape:'htmlall':'UTF-8'}" title="{l s='My loyalty' mod='xlpos'}" rel="nofollow"> <span class="link-item"> <i class="material-icons"></i> {l s='My loyalty' mod='xlpos'} </span> </a> <!-- /Module xlpos loyalty --> <!-- Module xlpos purchases --> <a class="col-lg-4 col-md-6 col-sm-6 col-xs-12" id="xlpos-ventesc-link" href="{$link->getModuleLink('xlpos', 'Ventesc', ['page' => 1, 'id_externe' => $id_externe, 'identfidelite' => $identfidelite], true)|escape:'htmlall':'UTF-8'}" title="{l s='My purchases' mod='xlpos'}" rel="nofollow"> <span class="link-item"> <i class="material-icons"></i> {l s='My purchases' mod='xlpos'} </span> </a> <!-- /Module xlpos purchases --> The «displayCustomerAccount» hook works fine (see ps_cust.jpg). But when I click on «My Purchases» I have an error (see error.jpg). I tried to clean the cache. When I remove the extends part of the template, the page is loaded … But it's ugly (the HTML contains only elements of the template file). Link to comment Share on other sites More sharing options...
bdesprez Posted January 15, 2021 Author Share Posted January 15, 2021 Sooo, I think I found the solution … DO NOT PUT «page» in the smarty assign … I replaced «page» by «num_page» and I now it works … It's good to know … 1 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