Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Try Vanilla Forums Cloud product

In this Discussion

After February 6, this site will no longer have Facebook, Twitter, or OpenID sign-in options. Read our announcement about social media SSO support in 2.8 for more info.

Make sure you have a current, valid email address set in your profile and set a password so you can login without it. If you get locked out after that time, you can choose "Forgot Password" to fix it as long as a valid email is on your account.

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.