I’m very new to the world of Discourse so please bear with me if this is a question that has been answered a million times.
I’ve created a script that needs to run each time the user navigates to the homepage or the categories page. Currently I am attempting to run it through the Customize > HTML/CSS > Head using <script> tags. I check for DOM load completion, but it looks like Discourse has a very unique way of loading pages as you navigate around the forum.
Refreshing the categories page executes the script, but after navigating to another page, then back to the categories, the script fails to run.
I’ve tried creating a plugin to see if it would work better that way (I got the example alert() plugin working, woo!), but I just don’t quite understand how to utilize everything that’s available.
Any suggestions on how to get a script to run each time I navigate to the categories page?
If you need more information to understand what I’m asking for, please let me know. Sometimes my wording makes sense to me, but not to everyone else!
Alright, I placed the code that @cpradio suggested in a CSS/HTML Customization page under the tab, but unfortunately it doesn’t seem to be working. Just to prove the concept, I have it try to display an alert. Below is the exact code I am using:
Oops! I just realized that right before you replied. Trying the plugin perspective now! If that doesn’t work, I will attempt to try the method you just posted. Thank you so much for your help!!
I like the look of a stacked subcategory list with the new post indication to the right of each category better than everything pretty much displayed inline.
For future reference, is there an ideal method to use when comparing the plugin vs. the CSS/HTML page implementation, or do they have the same performance and end result?
It should be nearly identical, both get preprocessed and minimized. The advantage the CSS/HTML has is you won’t have to do a container rebuild to pull in changes (or use the /admin/upgrade path), you can simply modify it within the Admin UI and save it to enable it (it may require a hard refresh of the browser though).