01generator Posted December 7, 2015 Share Posted December 7, 2015 Well I found an interesting problem to solve and I want to share it with you, firstly to find the best solution for me and anyone else out there who is facing the same problem. Ok let's caught to the chase, I have developed few modules that create a new tab for the admin menu. Well the modules are installing correctly and the tab is created with success, however the there is an issue. Tab is being created successfully and controller for the tab is registered with success, the issue appears when the controller is setting the template file. In the controller i use the following code $this->setTemplate('../../../../modules/mplimplom/views/templates/admin/mplimplomView.tpl'); Prestashop cloud returns an error cause it is trying to load the template file from the core template files. Here is the error Fatal error: Uncaught --> Smarty: Unable to load template file '/core/www/core_1.6.1.1/backoffice/themes/default/template/../../../../modules/mplimplom/views/templates/admin/mplimplomView.tpl' <-- thrown in /core/www/core_1.6.1.1/tools/smarty/sysplugins/smarty_internal_templatebase.php on line 129 Any pointers? Link to comment Share on other sites More sharing options...
01generator Posted December 8, 2015 Author Share Posted December 8, 2015 I have tried so far $tpl = $this->context->smarty->createTemplate(dirname(__FILE__) . '/../../views/templates/admin/mplimplomView.tpl'); return $tpl->fetch(); // Returns no error but the content is blank. Header footer menu of prestashop are loaded but no content of the template is displayed $tpl = $this->context->smarty->createTemplate('../../../../modules/mplimplom/views/templates/admin/mplimplomView.tpl'); return $tpl->fetch(); //Same result as the above! $tpl = $this->context->smarty->display('../../../../modules/mplimplom/views/templates/admin/mplimplomView.tpl'); return $tpl; // This code returns no errors and loads the template file, however it does not load all the template files of prestashop, for example right menu is missing, also few stylesheets seems to be missing too $tpl = $this->context->smarty->createTemplate('../../../../modules/mplimplom/views/templates/admin/mplimplomView.tpl'); return $tpl->display(); // Same as the above but it returns template errors. Such as Notice: Undefined index: msg in /home/pfr6621235/www/cache/smarty/compile/1e/26/3c/1e263c39db1e15e26b420e3bdb9141067527c022.file.mplimplomView.tpl.php on line 51 Link to comment Share on other sites More sharing options...
01generator Posted December 8, 2015 Author Share Posted December 8, 2015 $tpl = $this->context->smarty->display('../../../../modules/mplimplom/views/templates/admin/mplimplomView.tpl'); return $tpl->fetch(); // Loads only the template file nothing else By using the php get_class_methods($this->context->smarty) Array ( [0] => __construct [1] => clearCompiledTemplate [2] => clearAllCache [3] => clearCache [4] => check_compile_cache_invalidation [5] => fetch [6] => createTemplate [7] => check_template_invalidation [8] => update_filepath [9] => is_in_lazy_cache [10] => insert_in_lazy_cache [11] => delete_from_lazy_cache [12] => __destruct [13] => __clone [14] => __get [15] => __set [16] => templateExists [17] => getGlobal [18] => enableSecurity [19] => disableSecurity [20] => setTemplateDir [21] => addTemplateDir [22] => getTemplateDir [23] => setConfigDir [24] => addConfigDir [25] => getConfigDir [26] => setPluginsDir [27] => addPluginsDir [28] => getPluginsDir [29] => setCompileDir [30] => getCompileDir [31] => setCacheDir [32] => getCacheDir [33] => setDefaultModifiers [34] => addDefaultModifiers [35] => getDefaultModifiers [36] => setAutoloadFilters [37] => addAutoloadFilters [38] => getAutoloadFilters [39] => getDebugTemplate [40] => setDebugTemplate [41] => loadPlugin [42] => compileAllTemplates [43] => compileAllConfig [44] => getTags [45] => testInstall [46] => mutingErrorHandler [47] => muteExpectedErrors [48] => unmuteExpectedErrors [49] => display [50] => isCached [51] => createData [52] => registerPlugin [53] => unregisterPlugin [54] => registerResource [55] => unregisterResource [56] => registerCacheResource [57] => unregisterCacheResource [58] => registerObject [59] => getRegisteredObject [60] => unregisterObject [61] => registerClass [62] => registerDefaultPluginHandler [63] => registerDefaultTemplateHandler [64] => registerDefaultConfigHandler [65] => registerFilter [66] => unregisterFilter [67] => _get_filter_name [68] => loadFilter [69] => unloadFilter [70] => __call [71] => assign [72] => assignGlobal [73] => assignByRef [74] => append [75] => appendByRef [76] => getTemplateVars [77] => clearAssign [78] => clearAllAssign [79] => configLoad [80] => getVariable [81] => getConfigVariable [82] => getStreamVariable [83] => getConfigVars [84] => clearConfig ) And get_class_methods($this) Array ( [0] => __construct [1] => initContent [2] => processConfiguration [3] => setMedia [4] => getBaseUrl [5] => languageRetrieval [6] => generateUrls [7] => generateCSSfile [8] => createTemplate [9] => getTemplatePath [10] => initBreadcrumbs [11] => initToolbarTitle [12] => addFiltersToBreadcrumbs [13] => viewAccess [14] => checkToken [15] => processFilter [16] => postProcess [17] => processDeleteImage [18] => processExport [19] => processDelete [20] => processSave [21] => processAdd [22] => processUpdate [23] => processUpdateFields [24] => processStatus [25] => processPosition [26] => processResetFilters [27] => processUpdateOptions [28] => initPageHeaderToolbar [29] => initToolbar [30] => loadObject [31] => checkAccess [32] => filterToField [33] => displayNoSmarty [34] => displayAjax [35] => redirect [36] => display [37] => displayWarning [38] => displayInformation [39] => initHeader [40] => addRowAction [41] => addRowActionSkipList [42] => initTabModuleList [43] => addPageHeaderToolBarModulesListButton [44] => addToolBarModulesListButton [45] => filterTabModuleList [46] => initCursedPage [47] => initFooter [48] => initModal [49] => renderModal [50] => renderModulesList [51] => renderList [52] => getTemplateListVars [53] => renderView [54] => getTemplateViewVars [55] => renderDetails [56] => renderForm [57] => getTemplateFormVars [58] => renderKpis [59] => renderOptions [60] => setHelperDisplay [61] => setDeprecatedMedia [62] => l [63] => init [64] => initShopContext [65] => initProcess [66] => getList [67] => getModulesList [68] => getLanguages [69] => getFieldsValue [70] => getFieldValue [71] => validateRules [72] => _childValidation [73] => viewDetails [74] => beforeDelete [75] => afterDelete [76] => afterAdd [77] => afterUpdate [78] => afterImageUpload [79] => copyFromPost [80] => getSelectedAssoShop [81] => updateAssoShop [82] => validateField [83] => beforeUpdateOptions [84] => postImage [85] => uploadImage [86] => processBulkDelete [87] => ajaxProcessOpenHelp [88] => processBulkEnableSelection [89] => processBulkDisableSelection [90] => processBulkStatusSelection [91] => processBulkAffectZone [92] => beforeAdd [93] => displayRequiredFields [94] => jsonConfirmation [95] => jsonError [96] => isFresh [97] => refresh [98] => fillModuleData [99] => displayModuleOptions [100] => ajaxProcessGetModuleQuickView [101] => addMetaTitle [102] => getController [103] => run [104] => displayHeader [105] => displayHeaderJavaScript [106] => displayFooter [107] => setTemplate [108] => setRedirectAfter [109] => addCSS [110] => removeCSS [111] => addJS [112] => removeJS [113] => addJquery [114] => addJqueryUI [115] => addJqueryPlugin [116] => isXmlHttpRequest [117] => smartyOutputContent [118] => isCached [119] => myErrorHandler [120] => ajaxDie ) Link to comment Share on other sites More sharing options...
01generator Posted December 8, 2015 Author Share Posted December 8, 2015 $tpl = $this->getTemplatePath('../../../../modules/mplimplom/views/templates/admin/mplimplomExtraView.tpl'); return $tpl; // All are loaded except the template $tpl = $this->createTemplate('../../../../modules/mplimplom/views/templates/admin/mplimplomView.tpl'); return $tpl; // All are loaded except the template $tpl = $this->createTemplate('../../../../modules/mplimplom/views/templates/admin/mplimplomView.tpl'); return $tpl->fetch(); // AND $tpl = $this->createTemplate('../../../../modules/mplimplom/views/templates/admin/mplimplomView.tpl'); return $tpl->display(); // Returns Fatal error: Uncaught --> Smarty: Unable to load template file '/core/www/core_1.6.1.1/backoffice/themes/default/template/../../../../modules/mplimplom/views/templates/admin/mplimplomView.tpl' <-- thrown in /core/www/core_1.6.1.1/tools/smarty/sysplugins/smarty_internal_templatebase.php on line 129 Link to comment Share on other sites More sharing options...
01generator Posted December 11, 2015 Author Share Posted December 11, 2015 After careful investigation on $this object, I found out that the template directory is defined in there, however it is protected so you can simply change it by setting a new value. Any ideas how you can define a new template_dir to load tpl files from there for this controller? This of course might lead to a dead wall but it is the best idea to have right now. Link to comment Share on other sites More sharing options...
01generator Posted December 11, 2015 Author Share Posted December 11, 2015 I also have an idea of overriding somehow the tpl file... This discussion might end up useful or not... https://www.prestashop.com/forums/topic/232006-override-admin-template-tpl-file/?p=1394414 Link to comment Share on other sites More sharing options...
01generator Posted December 23, 2015 Author Share Posted December 23, 2015 No good answer is found yet. Let me re inform you about the issue. I have created a module that installs a tab in backoffice and a controller is assign to it. In the controller the module calls the template file like return $this->setTemplate('mplimploumView.tpl'); All works fine! BUT not in prestashop cloud Results in Fatal error: Uncaught --> Smarty: Unable to load template file '/core/www/core_1.6.1.1/backoffice/themes/default/template/mplimploumView.tpl' <-- thrown in /core/www/core_1.6.1.1/tools/smarty/sysplugins/smarty_internal_templatebase.php on line 129 In prestashop cloud certain files are loaded from core folders that are being used by all shops. Is there a ways to override the core template files or to declare which tpl file I want to display. Any help would be much appreciated cause I am really stuck. 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