# Overwriting controllers in plugin

**URL:** https://meta.discourse.org/t/overwriting-controllers-in-plugin/40675
**Category:** Development
**Created:** [March 7, 2016, 7:03am UTC](https://meta.discourse.org/t/overwriting-controllers-in-plugin/40675 "2016-03-07T07:03:06Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Steve\_Ng](https://avatars.discourse-cdn.com/v4/letter/s/3be4f8/32.png) [@Steve\_Ng](https://meta.discourse.org/u/Steve_Ng)
#### Post date: [March 7, 2016, 7:03am UTC](https://meta.discourse.org/t/overwriting-controllers-in-plugin/40675/1 "2016-03-07T07:03:06Z")

</div>

Hi, I wanted to add additionally functionality through a plugin.

I added a topic controller at plugins/xx/assets/javascripts/discourse/controllers/topic.js.es6

and I have

```plaintext
import TopicController from 'discourse/controllers/topic';
export default TopicController.reopen({
   actions: {
      own_actions:function() { debugger; };
   }
});

```

when I tried to call the action from my topic.hbs template, it says action own\_action is not found. is theer anything I would have to do to initialize this controller?

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [March 7, 2016, 8:24am UTC](https://meta.discourse.org/t/overwriting-controllers-in-plugin/40675/2 "2016-03-07T08:24:49Z")

</div>

Ideally, you’ll want to `reopen` the controller inside an `initializer`.

Have a look at the “initialize code” section under [Developing Discourse Plugins - Part 1 - Create a basic plugin](https://meta.discourse.org/t/beginners-guide-to-creating-discourse-plugins/30515). 🙂

---

<div class="post-metadata">

### Author: ![joebuhlig](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/joebuhlig/32/193054_2.png) [@joebuhlig](https://meta.discourse.org/u/joebuhlig)
#### Post date: [March 7, 2016, 3:36pm UTC](https://meta.discourse.org/t/overwriting-controllers-in-plugin/40675/3 "2016-03-07T15:36:39Z")

</div>

If you want another example, take a look at the [voting plugin](https://meta.discourse.org/t/discourse-feature-voting/40121). I do something similar there. It’s not from the controller itself but it’s close.

[https://github.com/joebuhlig/discourse-feature-voting/blob/master/assets/javascripts/initializers/feature-voting.js.es6](https://github.com/joebuhlig/discourse-feature-voting/blob/master/assets/javascripts/initializers/feature-voting.js.es6)
