Overriding core functions and classes

From e107 Wiki
Jump to: navigation, search

e107 Wiki: English | Русский | Deutsch | Français | Magyar | Português | Български | Česky | Nederlands | Ελληνικά | Italiano | Norske | Polska | Slovenščina | Español | Svenska | Translate: Wiki | Page


Current Release 1.0.4 | e107.org | Download | Changelog | Forum | Plugins | Themes | RSS Feed of Latest Changes | Atom Feed of Latest Changes

Development part of the e107 handbook
Main page > I : First Aid > II : Development > III : Administration > IV : How To's > V : Plugin Writing > VI : Theming & Shortcodes

As of v0.7, e107 has the ability for themes and plugins to override core functions and classes and define them for themselves.

The following can be overridden:

  • tablerender()
  • render_newsitem()

To override these you do the following from your plugins e_module.php file. See Modules or the section on theme overrides for the procedure for overriding from theme.php):

Please note - there are rules to prevent multiple plugins and themes causing a parse error when they all try to override the same code. The rules are that each in turn overrides the other's override code in this order:

plugin 1 => gets overridden by plugin 2 => which gets overridden by theme

Because of these potential conflicts its advisable to find alternative ways of achieving your aim without using overrides.

In the following example code you replace 'yourplugin' with the directory name of your plugin and place your alternative code to the default core code where we have placed the example echo "overridden"; code. This block of code will be used instead of the core code it is replacing.





This is the function that takes the data output of a menu and passes it to your themes tablestyle() function in order to be rendered and displayed on your page.

For tablerender():

Code: overriding tablerender()
$override->override_function('tablerender', 'yourplugin_tablerender', 1);
function yourplugin_tablerender(){
   echo "tablerender overridden";