Looking for advice on how to create a different homepage


#1

Hi folks,
I have looked into the several topics in this category for either a blog-like homepage or a curated homepage but nothing yet fits what I am really looking to build.

So, I came up with a mockup and I am wondering what the best way would be to go about achieving what’s designed in the mockup.

What I am looking to do would have the following features:

Left column

  • A blog-like list of topics on the left column sorted by the post date of the initial topic (not replies). This would only apply to this page (not to any other topic lists on the site, i.e. I like the table display of topics for all other lists).
  • The topics in this list would show an excerpt and a photo, and the photo should ideally only be shown ifit is embedded before the second paragraph of the post. (This would allow for some posts to not have photos, or even to have photos later in the contents but not in this “homepage” display.) The Topic List Previews plugin seems like an excellent starting point for this part of what I am trying to build (although it modifies the reusable Discourse list item display, which isn’t my goal here).

Right column

Three separate blocks here (or more), but essentially: 1) a list of recent comments (very much like classic blogs), a custom area for messages and 3) a quick snapshot of new replies, but organized by category (could the Categories page be pulled in here?).

(On mobile, the right column would drop either completely or below the left sidebar. Depending on whether the contents of the blog-like flow on the left can load on scrolling down the page.)

So, if I were to start building this as a plugin (or as a few plugins, maybe) how do I go about starting this?:

  1. How do I set up a “page” in a Discourse plugin? Or is this even doable? (By the way, I would prefer to have this homepage as another item in the menu, next to Latest, etc.)
  2. The query to display the topics from a particular tag on this page, should it be written in Rails or in Ember? I’m a frontend developer, so CSS/Ember are things I can work my way around, Rails less so.
  3. Are there any other plugins whose code would be good inspiration for me?

Topic List Previews
Topic List Previews
(Angus McLeod) #2

Definitely possible. Start by looking at how the Tagging Plugin creates the tags index route. If you encounter any seemingly insurmountable issues, ping us here and I’m sure we can overcome them.

Javascript. You can get the topic list from the store like Quick Messages does, or you can pull it from the server directly yourself, along the lines of:

    var url = '/c/' + category.slug;
    Discourse.ajax(url + ".json", {cache: true}).then((result) => {
      topics = result.topic_list.topics.filter((topic)=>{return topic.tags && topic.tags.indexOf('blah') > -1}),
      return topics
    })

You can treat the server like a JSON api. There’s a bunch of JSON endpoints. Start sticking .json after any route and you’ll soon discover them.

Could you elaborate on what you mean by “modifies the reusable Discourse list item display”?