I make changes in discourse application where I want to show to topics according to number of replies, I created rails query but I am no able to find out the view part, Where I need to show and adding this scope.
If you want to change how Discourse behaves, you’ll need to see Developing Discourse Plugins - Part 1 - Create a basic plugin or perhaps Beginner’s guide to developing Discourse Themes.
I don’t want to create new plugin, I just want to change the category & topic queries from backend side and want to show on view, but Can’t find out where the list of topics link are shown.
There is a category setting that might work for that:
If you need to change the code, you should make your changes in a plugin. Making changes to the core code will cause you problems in the future.
Okay Simon, Thank you
I think It will help me out
I want to sort this right side links of topics for particular catgeory based on highest number of topics, It will need to change the modification on backend side right?
I don’t think you need to modify code for this, but you may need to run a command from your site’s rails console to get the topics to display in the new order on your site’s homepage.
When you select “Categories with Featured Topics” for the desktop category page style
site setting, the order that the featured topics are displayed in should be set by the value of each category’s “Topic List Sort By” setting. Unfortunately, if you make a change to a category’s “Topic List Sort By” setting, that change is not immediately shown on the site’s homepage. I am not sure where Discourse is caching the featured topics that are displayed on the home or what action is used by Discourse to trigger breaking the cache.
From testing on my own site, I see that the cache can be broken by running the following from the rails console:
# Assign the category you want to fix the results for to a variable, for example:
c = Category.find(42)
# Then run
CategoryFeaturedTopic.feature_topics_for(c)
After running that, the topics should get displayed on the homepage in the order you selected for the category’s “Topic List Sort By” setting. I don’t think that running that command can cause any issues, but always be careful running commands from the rails console.
I’m sure there is an easier way to do this. Possibly you just need to wait for up to 24 hours for Discourse to break the cache on the old featured topic list. I’m not seeing where in the code the cache is broken. The relevant code seems to be here: discourse/category_featured_topic.rb at main · discourse/discourse · GitHub.
I hit that query but main problem is that where this featured topics are displayed on the home, on which .html file have code to shown this data on UI.
I already made a queries for what data I need to sort but problem is where I put the query into which model.