Discourse Sidebar Blocks

(Penar Musaraj) #41

You most likely have something in the first category that forces the topic table to be pushed beyond its set width. This could be, for example, a long text string in the title or the excerpt, like a URL. It can be fixed by setting white-space:wrap on the excerpt.

Happy to assist if you have a link.

(xiasummer) #42

(Bolarinwa Balogun) #43

I am new to discourse and was trying to get the sidebar blocks to appear on the topics page. I am trying to use the sidebar block as a quick navigation tool. Any ideas about how I can achieve this?
Thank you.

(Penar Musaraj) #44

Sidebar blocks is limited to lists, it doesn’t have the functionality to display in a topic page.

Maybe try the layouts plugin (on phone, can’t get the link easily).

(Anshul Kushwaha) #45

Created a PR to add Leaderboard Block.
Also added two settings for number and period for the leaderboard.

Might continue to improve this. Using this at forum.trainman.in
49 PM

(Andrew Small) #46

Any chance you can support iframes in the custom html? I want to add a gametracker server stat.


(Bolarinwa Balogun) #47

I was wondering how I would go about adding categories to the sidebar block.

Thank you

(Penar Musaraj) #48

@Smallo I haven’t tried iframes. Did you try? Does it result in an error?

@Bolarinwa_Balogun feel free to send a PR with a block that lists categories. Would be happy to review it.

(Andrew Small) #49

It doesnt result in an error. It just doesn’t do anything. The iframe I try is this one. It works in basic HTML. Just not on discourse.

<iframe src="http://cache.gametracker.com/components/html0/?host=" frameborder="0" scrolling="no" width="240" height="348"></iframe>

(Penar Musaraj) #50

I just tried it on my Discourse site, and it worked. I bet your Discourse site is in https, make sure you use https in the iframe’s url too.

(Andrew Small) #51

oh shit you’re right. I feel dumb. Haha thanks

(Jay Abie) #52

i installed the plugin and the latest replies are showing now on the sidebar how i can add list of categories? also can i add advertisement ? if not what i can add to the sidebar in total ?

(Bolarinwa Balogun) #53

I was trying to create a block that lists categories. I am using the latest replies as a guide.

const messageBus = Discourse.__container__.lookup('message-bus:main')
    messageBus.subscribe("/latest", data => {

I was wondering what the above line of code does?

Thank you.

(Penar Musaraj) #54

The line in question will refresh the block if there are new things posted under /latest. You likely don’t need it in a list of categories.

(Bolarinwa Balogun) #55

I was able to add a block that lists categories. I was wondering if it possible to list items horizontally?


(Penar Musaraj) #56

I’m not sure I understand how tou wanna display them horizontally, but you can do that with css. Either items inside the block, or the qhole sidebar.

(Bolarinwa Balogun) #57

Thanks for consistently answering my questions. I wanted to know what the code snippet below does?

export function getLatestPosts(context) {
  const container = Discourse.__container__;
  const store = container.lookup('store:main');
  var filter = "c/" + context.attrs.category;

Thank you.

(Penar Musaraj) #58

Well, you need to see those lines in context. The full function is this:

export function getLatestPosts(context) {
  const container = Discourse.__container__;
  const store = container.lookup('store:main');
  var filter = "c/" + context.attrs.category;
  return store.findFiltered("topicList", {filter: filter}).then((result) => {
    return result.topic_list.topics;
  }).catch(() => {
    console.log('getting topic list failed')
    return [];

So the first two lines in the function set up the store, the third line sets up the filter, and then we run findFiltered on the store to, well, find the posts based on that filter.


Nice Plugin @pmusaraj !

Spanish translations PR’s already been sent :es:

(Penar Musaraj) #60

The PR is now merged, thank you!