In a discussion about adding custom sidebar buttons in Discourse, Truest seeks to add a button labeled “Install” to the sidebar (via the hamburger menu or bottom section) and connect it with JavaScript. Their initial attempt using HTML in the component’s <body> failed. Arkshine advises using the addCommunitySectionLink API, pointing to documentation and suggesting placing the script in the <head> with the correct <script type="text/discourse-plugin" version="0.8"> wrapper. Truest tries this but still sees no effect. Arkshine confirms the script must be in the head with the proper plugin script type. Truest then tries again with route: "discovery.latest" and icon: "download", but reports that while the button appears, clicking it doesn’t trigger the intended script — oddly, the script only runs when clicking the default “Topic” button. They note the script is also placed in the head, indicating a possible routing or event binding issue with the custom link.
I would like to add it in the form of a button in the sidebar (hamburger menu) → More or at the bottom of the sidebar and then connect JavaScript. How do I access the Discourse sidebar to do that?
I did the following, but it didn’t work.
I put it in the of the component.
I tried to add the above code to the sidebar’s view, but it did not work, so I wrote it in the format below, referring to the existing path. However, when the button appears and I press it, the script does not seem to work properly. Oddly enough, the script works when I press the ‘Topic’ button rather than the button I created. The script to be connected was also placed in the head of the HTML.