How to add custom data to Discussion API

I read this https://docs.vanillaforums.com/help/apiv2/swagger/#/Discussions/get_discussions
I want add more data to API result, such as 'body_excerpt'. How to inject custom data into API result?

Comments

  • R_JR_J Cheerleader & Troubleshooter Munich Moderator

    Man, thanks for that question - it made me learn something new! But the answer to your question is quite conventional: you need a custom plugin for that.
    It doesn't have to be complicated, though. It only needs to have one one method:

        public function discussionsApiController_getOutput_handler($result) {
            $result['body_excerpt'] = Gdn_Format::excerpt(
                $result['body'],
                $result['format']
            );
            return $result;
        }
    


    BleistivtShadowdare
Sign In or Register to comment.