Invision Community 5: A video walkthrough creating a custom theme and homepage By Matt Thursday at 04:02 PM
Tom S. Posted March 14, 2019 Posted March 14, 2019 Hello, As I understand it, I can extend a class using code hooks in plugins. So, if I wanted to modify a method for the cart class I could do this inside of my plugin: class cart extends _HOOK_CLASS_ { protected function clear() { // some code } } Am I right in thinking I will completely override the clear() method with that? My question is how can I add some extra functionality to the clear() method without completely overriding it? Say, for example, I wanted to add an extra line to that method making a change to a table in the database (but keep the rest of the functionality the same). How could I do that? I read that just copying the entire method into my hook is against the terms. Thanks.
Aiwa Posted March 14, 2019 Posted March 14, 2019 // your code return parent::clear(); Or the opposite, if you need to manipulate the data.. $return = parent::clear(); // your code return $return;
Daniel F Posted March 14, 2019 Posted March 14, 2019 Depending on what you want to accomplish you'll need to run your code before or after you call parent::clear(); ( which will then execute the original clear method)
Recommended Posts
Archived
This topic is now archived and is closed to further replies.