rkaplan
16 בינואר, 2019, 4:25am
1
I was reading this blog article
Consider the typical sections of a daily newspaper: Arts, Sports, Business, Travel, Local, and World. Any given article belongs to just one of those sections, and the content in each section is quite different, such that some people, for example, may...
and I noticed a reference to “tag queries” on a custom home page:
I know that I can search by tag with the format tags:XXX in the search bar. I also know that I can re-create the search via the resulting URL. But what I do not understand is how to retrieve for a home page or static page just the list of posts corresponding to the search and not all the other stuff in a search response.
Do I need to use the API and build a web app to get a custom query such as this - or is there some other trick?
The custom homepage you’re referencing pulls in the topics from a tag using AJAX and an endpoint like this:
https://meta.discourse.org/tags/theme.json
If you want to get the contents of a search (can you clarify what you mean by “all the other stuff”?):
https://meta.discourse.org/search.json?q=reverse%20engineer&expanded=true
For more details about finding the data that populates a specific page, you can look here:
Discourse is backed by a complete JSON api. Anything you can do on the site you can also do using the JSON api.
Many of the endpoints are properly documented in the discourse_api gem, however some endpoints lack documentation.
To determine how to do something with the JSON API here are some steps you can follow.
Example: recategorize a topic.
Go to a topic and start editing a category:
[image]
Open Chrome dev tools, switch to the Network tab, select XHR filter:
[image]
Perform the op…
2 לייקים