Discourse Sidebar Blocks

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.

Hi,
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.

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).

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

https://github.com/pmusaraj/discourse-sidebar-blocks/pull/4

5 Likes

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

@pmusaraj

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

Thank you

@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.

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=180.92.199.115:9987&bgColor=FFFFFF&fontColor=333333&titleBgColor=FFFFFF&titleColor=000000&borderColor=BBBBBB&linkColor=091858&borderLinkColor=5C5C5C&showMap=0&currentPlayersHeight=160&showCurrPlayers=1&showTopPlayers=0&showBlogs=0&width=240" frameborder="0" scrolling="no" width="240" height="348"></iframe>

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.

1 Like

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

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 ?

Hi,
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 => {
    this.refreshPosts();
    });

I was wondering what the above line of code does?

Thank you.

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.

1 Like

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

Thanks

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.

1 Like

Hi,
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.

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.

3 Likes

Nice Plugin @pmusaraj !

Spanish translations PR’s already been sent :es:

3 Likes

The PR is now merged, thank you!

2 Likes