hei Posted December 22, 2015 Share Posted December 22, 2015 Hi, I want to add a new page, differently by cms, in my website. I've created controller file: <?php class NegoziantiController extends FrontController { /* public function setMedia() { $this->context->controller->addJS(_THEME_JS_DIR_ . 'custom-page.js'); $this->context->controller->addCSS(_THEME_CSS_DIR_ . 'custom-page.css'); parent::setMedia(); }*/ public function initContent() { $res = Db::getInstance()->executeS(' SELECT `shop_name`, `link_rewrite` FROM `'._DB_PREFIX_.'marketplace_shop'); foreach($res as $finale){ $finale_due = array(array(‘nome’ => $finale['shop_name'], ‘link’ => $finale['link_rewrite'])); } /*preparingdata for passing to the custom page*/ $this->context->smarty->assign('finale' => $finale); /*data ends-here*/ /*pass data to template file*/ $this->setTemplate(_PS_THEME_DIR_ . 'negozianti.tpl'); /*show left/ right columns - will be true and shown by default*/ $this->display_column_left = false; $this->display_column_right = false; /*call parent initcontent - this is for loading the site's default header, footer, left and right columns*/ parent::initContent(); } } ?> And tpl file added in template root: <h3>Ciao</h3> <p><strong>Test</strong></p> <ul> {foreach from=$finale_due item=skill} <li>{$skill}</li> {/foreach} </ul> But nothign happens, what's wrong? Can u help me? Matteo Link to comment Share on other sites More sharing options...
yaniv14 Posted December 23, 2015 Share Posted December 23, 2015 Are you able to reach the page? do you see something or unable to load the controller? did you added the page controller under seo & urls? did you placed the files in the correct folders (controller/front & themes/your_theme)? try to add above the public functions: public $php_self = 'negozianti'; Link to comment Share on other sites More sharing options...
hei Posted December 28, 2015 Author Share Posted December 28, 2015 Do all! ATM i've tryed $php_self = 'negozianti'; with no success, added in override/controllers/front/NegoziantiController.php Link to comment Share on other sites More sharing options...
yaniv14 Posted December 28, 2015 Share Posted December 28, 2015 Try to place the controller inside the root controllers/front and not inside override/controllers/front. Try to disable friendly url and try reaching the page with: http://www,yourshop.com/index.php?controller=negozianti Link to comment Share on other sites More sharing options...
hei Posted December 28, 2015 Author Share Posted December 28, 2015 Load and load again, my friend. Nothing. <?php class NegoziantiController extends FrontController { public function initContent() { $aio = array('fname' => 'John', 'lname' => 'Doe', 'email' => '[email protected]'); /*preparingdata for passing to the custom page*/ $this->context->smarty->assign('aio' => $aio); /*data ends-here*/ /*pass data to template file*/ $this->setTemplate(_PS_THEME_DIR_ . 'negozianti.tpl'); /*show left/ right columns - will be true and shown by default*/ $this->display_column_left = false; $this->display_column_right = false; /*call parent initcontent - this is for loading the site's default header, footer, left and right columns*/ parent::initContent(); } $php_self = 'negozianti'; } ?> code right now. Link to comment Share on other sites More sharing options...
razaro Posted December 28, 2015 Share Posted December 28, 2015 Try maybe to rename your class to NegoziantiControllerCore . Also try to put parent::initContent(); at beginning of your initContent function. And it does need to be in root/controller/front. Link to comment Share on other sites More sharing options...
ventura Posted December 28, 2015 Share Posted December 28, 2015 you also have to remove the file /cache/class_index.php for this to become regenerate with changes 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