H4818 Posted February 23, 2014 Share Posted February 23, 2014 I have module with the following code which is not displaying in my back office: module name: vendorprog vendorprog/controllers/admin/AdminVendorController.php <?php if (!defined('_PS_VERSION_')) exit; class AdminVendorController extends ModuleAdminController { public function __construct() { ppp('__construct called'); $this->display = 'view'; parent::__construct(); } public function initContent() { $this->renderView(); } public function renderView() { ppp($this->getTemplatePath()); $this->base_tpl_view = 'report.tpl'; return parent::renderView(); } } I have a file at /vendorprog/views/templates/admin/helpers/view/report.tpl with the following code: <p>Hello World</p> I get the following error: Fatal error: Uncaught exception 'SmartyException' with message 'Unable to load template file 'helpers/view/report.tpl'' How can I solve this? I still want to add functions that can be called through ajax. Please help Link to comment Share on other sites More sharing options...
johnmark Posted August 1, 2014 Share Posted August 1, 2014 Trying to follow module "gamification" to create my own one, but encounter the same error, any hints to resolve it? Link to comment Share on other sites More sharing options...
Patrick T. Posted November 21, 2014 Share Posted November 21, 2014 Hi to every one, for your custom tpl file, can use the function $this->context->smarty->createTemplate(<tpl_file_path>, $this->context->smarty); The custom template file need to be in the directory of your module, in path views/templates/admin Besta regards, Patrick T. Link to comment Share on other sites More sharing options...
gonebdg - webindoshop.com Posted November 26, 2014 Share Posted November 26, 2014 If your module name is vendorprog , and the controller class name is AdminVendorController then you set the base template name like this : $this->base_tpl_view = 'report.tpl'; . You should place the template file on : ../modules/vendorprog/views/templates/admin/vendor/helpers/view/report.tpl . BUT ... why you are using ppp() function which is an alias of dieObject() function within your controller __contruct() and renderView() method ? ppp('__construct called');// will print: __construct called ppp($this->getTemplatePath());// will print simliar to: /modules/vendorprog/views/templates/admin/ . And according to your AdminVendorController.php file, the following code won't display the content of your report.tpl file return parent::renderView(); Link to comment Share on other sites More sharing options...
VinayC Posted August 27, 2015 Share Posted August 27, 2015 Hi, I'm trying to create tab under dashboard. I was able to get name of the tab. But I'm facing problem when trying to renderView. Below code is for Controller <?php class AdminHomePageController extends ModuleAdminController{ public function __construct(){ $this->table = 'homepage_tab'; $this->className = 'AdminHomePage'; $this->module = 'homepage'; $this->fiels_list = array( 'id' => array('title' => $this->l('id'), 'align' => 'center', 'width'=>25), 'title' => array('title' => $this->l('Title'), 'align' => 'center', 'width' => 25), 'image_path' => array('title' => $this->l('Image Path'), 'align' => 'center', 'width' => 25), 'assoc_link' => array('title' => $this->l('Associated Link'), 'align' => 'center', 'width' => 25), 'date_add' => array('title' => $this->l('Date Added'), 'align' => 'center', 'width' => 25), ); $this->bootstrap = true; parent::__construct(); $this->meta_title = $this->l('Webservice Settings'); $this->toolbar_title[] = $this->meta_title; } public function initContent(){ $this->renderView(); } public function renderView(){ $tpl = $this->context->smarty->createTemplate(dirname(__FILE__).'../../views/templates/admin/displayAdminProductsExtra.tpl'); return $tpl->fetch(); } } Below is .tpl code <h3 class="page-product-heading">AdminTab</h3><div class="rte"> <form action="" method="post" id="comment-form"> <div class="form-group"> <label for="title">Title:</label> <input type="text" name="title" id="title" class="form-control"> </div> <div class="form-group"> <label for="image">Image Path:</label> <input type="text" name="image" id="image" class="form-control"> </div> <div class="form-group"> <label for="assoc_link">Associated Link:</label> <input type="text" name="assoc_link" id="assoc_link" class="form-control"> </div> <div class="panel-footer"> <a href="{$link->getAdminLink('AdminProducts')}" class="btn btn-default"><i class="process-icon-cancel"></i> {l s='Cancel'}</a> <button type="submit" name="submitAddproduct" class="btn btn-default pull-right"><i class="process-icon-save"></i> {l s='Save'}</button> <button type="submit" name="submitAddproductAndStay" class="btn btn-default pull-right"><i class="process-icon-save"></i> {l s='Save and stay'}</button> </div> </form> </div> Can any one please help to display the content of tpl? Error that I'm getting is Uncaught --> Smarty: Unable to load template file I need to fetch the table from db and display it that tab which comes under dashboard. Any help would be great. Thanks in advance. Link to comment Share on other sites More sharing options...
zsigmondszilveszter Posted November 18, 2015 Share Posted November 18, 2015 Hi, I am a presta newbie and I have a similar problem, I created a custom module with custom controller, then under Administration->Menus I created a new admin menu with the new module and controller. After that I created a test template file under "modules/szilveszterfirst/views/templates/admin/szilveszter_first/helpers/view/test.tpl". Everything works fine, except the renderView function, the template file is loaded(I printed out the result), but in the admin page doesn't show anything. Is there any prerequisite, that I didn't do? e.g. the template should contain something special(actually contains a few html tags for test sake)? class AdminSzilveszterFirstController extends ModuleAdminController { public function __construct() { $this->lang = false; parent::__construct(); } public function initContent(){ $this-> renderView(); return parent::initContent(); } public function renderView() { $this->base_tpl_view = 'test.tpl'; //printf("<pre>%s</pre>",print_r(parent::renderView(),true)); return parent::renderView(); } } Link to comment Share on other sites More sharing options...
nicknic92 Posted June 22, 2016 Share Posted June 22, 2016 so this topic still don't have any solution? Link to comment Share on other sites More sharing options...
plup Posted September 10, 2016 Share Posted September 10, 2016 (edited) Hi guys, I have basically the same code than VinayC : class AdminPillowGeneratorFabricController extends ModuleAdminController { public function __construct() { $this->className = 'PillowGeneratorFabric'; // Model class name $this->table = 'pillowgenerator_fabric'; // Table in database (without prefix) // Using view list helper $this->fields_list = array( 'id_pillowgenerator_fabric' => array( 'title' => $this->l('ID'), 'align' => 'center', 'width' => 25), 'name' => array( 'title' => $this->l('Name'), 'align' => 'center', 'width' => 100), ), ); $this->bootstrap = true; parent::__construct(); } public function renderView() { $tpl = $this->context->smarty->createTemplate(_PS_MODULE_DIR_.'/pillowgenerator/views/templates/admin/fabric_view.tpl'); return $tpl->fetch(); } } But the View button give me this error : Fatal error: Class 'PillowGeneratorFabric' not found in /var/www/html/classes/controller/AdminController.php on line 1617 As far as I search nobody found a clear solution to this problem. Any news ? Edited September 10, 2016 by plup (see edit history) 1 Link to comment Share on other sites More sharing options...
plup Posted September 10, 2016 Share Posted September 10, 2016 (edited) Well, I usual, I searched for a full day and the answer becomes obvious when I post on the forum. I forgot to include my model in my controller... So this code works actually well. Edited September 10, 2016 by plup (see edit history) Link to comment Share on other sites More sharing options...
yined Posted May 7, 2020 Share Posted May 7, 2020 @plup Super eh solucionado. 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