peorthyr Posted May 26, 2014 Share Posted May 26, 2014 (edited) Good day all. Sometimes I've found some workarounds to satisfy some kind of needs that explain how to extend some core functionality by editing files like tools.php or frontendController.php. The last one I've found that saved my life, was a function to retrieve the name of a cms page starting from its id and the language id: public static function getCMSTitle($id_cms,$id_lang){ $cms = new CMS($id_cms, $id_lang); return $cms->meta_title; } <li><a href="{$link->getCMSLink(1)}">{Tools::getCMSTitle(1,$cookie->id_lang)}</a></li> stackoverflow link my question is: Is it possible to think at these modifications in terms of modules? I mean, is possible to write a module that gives a functionality similar to this, so that expose a new method in all the pages and that can be called in tpl files? and most important, it NOT alter the core code, so the shop remain upgradable, and the module could be upgraded as needed. Edited May 26, 2014 by peorthyr (see edit history) Link to comment Share on other sites More sharing options...
PascalVG Posted May 26, 2014 Share Posted May 26, 2014 You could make a new class MyTools.php, where you add the function, instead of directly in Tools.php, and then use: <li><a href="{$link->getCMSLink(1)}">{MyTools::getCMSTitle(1,$cookie->id_lang)}</a></li> Just an idea... My $0.02, pascal. 1 Link to comment Share on other sites More sharing options...
peorthyr Posted May 26, 2014 Author Share Posted May 26, 2014 that should be a way indeed, nice idea Link to comment Share on other sites More sharing options...
Rolige Posted May 26, 2014 Share Posted May 26, 2014 (edited) Maybe you will need delete class_index.php If new class_index.php doesn't take the new class, then you will need add it manually Edited May 26, 2014 by COTOKO (see edit history) Link to comment Share on other sites More sharing options...
peorthyr Posted May 29, 2014 Author Share Posted May 29, 2014 is it possible to override the classes in the theme like we can do with module files? Link to comment Share on other sites More sharing options...
Rolige Posted May 29, 2014 Share Posted May 29, 2014 is it possible to override the classes in the theme like we can do with module files? I don't think so, because I've never seen anything like that. Link to comment Share on other sites More sharing options...
vekia Posted May 29, 2014 Share Posted May 29, 2014 you can't override module php files in theme directory, you can do it only with css/js/.tpl files 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