IndianaJoe Posted November 18, 2017 Share Posted November 18, 2017 How do we do custom database hooks when a record is saved, deleted, or edited? I was able to do this in 3.x but can't find it in 4.2. Thanks Link to comment Share on other sites More sharing options...
bfarber Posted November 20, 2017 Share Posted November 20, 2017 You create a hook on \IPS\cms\RecordsX where X is the database ID, and then overload the methods you need to overload (e.g. delete(), postEditSave(), etc.) Link to comment Share on other sites More sharing options...
IndianaJoe Posted November 20, 2017 Author Share Posted November 20, 2017 Couple questions 1. Do I create a new file, if so where do I put it? 2. Where can I find the functions I can overwrite? 3. In 3.4.7 I did this, does the format of the file stay the same? Here is an example. <?php class database_callback_19 // rename this class to match the number of your IP.Content table { public function __construct( $registry ) { } public function postSave($newData) { blah blah blah return $newData; } } ?> Thanks Link to comment Share on other sites More sharing options...
Daniel F Posted November 20, 2017 Share Posted November 20, 2017 Please see our documentation for further information about hooks Link to comment Share on other sites More sharing options...
IndianaJoe Posted November 20, 2017 Author Share Posted November 20, 2017 I've spent a lot of time there, but it doesn't give me the specific answers I needed. Link to comment Share on other sites More sharing options...
Ryan Ashbrook Posted November 20, 2017 Share Posted November 20, 2017 You create the file in the Developer Center - click the menu to the right of your application / plugin, then click Developer Center. You can create them under the Hooks tab. As far as what methods can be overloaded - this is any method contained in the following classes, listed by inheritance order. The Developer Center will also show you this information if you edit the hook you just created. \IPS\cms\RecordsX (this is a pseudo class created by an autoloader contained in /applications/cms/Application.php specific to the database, where X is the ID of that database) \IPS\cms\Records (/applications/cms/sources/Records/Records.php) \IPS\Content\Item (/system/Content/Item.php) \IPS\Content (/system/Content/Content.php) \IPS\Patterns\ActiveRecord (/system/Patterns/ActiveRecord.php) Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.