# Pouvez-vous remplacer n'importe quel fichier dans Discourse via un plugin ?

**URL:** https://meta.discourse.org/t/can-you-override-any-file-in-discourse-via-a-plugin/179836
**Category:** Development
**Created:** [Février 16, 2021, 12:15 UTC](https://meta.discourse.org/t/can-you-override-any-file-in-discourse-via-a-plugin/179836 "2021-02-16T00:15:48Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![hawm](https://avatars.discourse-cdn.com/v4/letter/h/f07891/32.png) [@hawm](https://meta.discourse.org/u/hawm)
#### Post date: [Février 16, 2021, 5:44 UTC](https://meta.discourse.org/t/can-you-override-any-file-in-discourse-via-a-plugin/179836/2 "2021-02-16T05:44:09Z")

</div>

Non, vous remplacez une classe ou une méthode plutôt qu’un fichier, donc le nom du fichier n’a peut-être pas d’importance. Si vous ne connaissez pas la structure des plugins, vous pouvez consulter le code source officiel de certains plugins.

> [@Override existing Discourse methods in plugins](https://meta.discourse.org/t/tips-for-overriding-existing-discourse-methods-in-plugins/83389):
>
> I’ve been running into a bunch of instances recently of needing to override existing ruby methods from plugins, and thought I’d share my best practices here. Overriding an instance method class ::TopicQuery module BabbleDefaultResults def default\_results(options={}) super(options).where('archetype \<\> ?', Archetype.chat) end end prepend BabbleDefaultResults end Here I’m removing chat topics from an instance method which is returning a list of topics. The module name BabbleD…

---

_[View the full topic](https://meta.discourse.org/t/can-you-override-any-file-in-discourse-via-a-plugin/179836)._
