Blog post plugin

(Simon Cossar) #1

Continuing the discussion from Could I show the best posts in a seperate view like WordPress?:

Note: this plugin is broken. It is no longer being maintained.

Edit: I’ve completely rewritten this plugin. See this post for details.

I’ve made a plugin for doing something like this. You can find it here: GitHub - scossar/discourse-blog-post: Adds a blog post class to Discourse

It lets you select a category to display with different styles than the rest of your forum. It defaults to the ‘blog’ category, but that can be changed in the settings. It selects an image that has the added class header-image and creates a full-width splash image out of it. The styles are quite basic. They mostly involve removing things. At the moment it’s removing the reply controls. That could be changed. It adds the class blog-post to the body tag for topics of the chosen category. Custom styles can be added by beginning them with the .blog-post selector.

This isn’t quite ready for production. The styles need a few tweaks. Pull requests and suggestions are welcome.

Optional blog-like “homepage” for the forum
[Paid] Art gallery plugin
Formatting toolbar
(徐徐浩) #2

I love this blog view, thanks for sharing this with us.

(徐徐浩) #3

is it possible to copy a post to post to your blog category? I mean, could i simply add a post from other categories to this post category. I want to use this as a place to show the best posts.

(Simon Cossar) #4

The way it works now you would have to change the category of your post to whatever you have set as the blog-post category. Maybe it could be setup to work with tags instead, so that if you tagged a post as ‘featured’ it would get this view.

(徐徐浩) #5

the idea of tag is brilliant

(Simon Cossar) #6

I’ve rewritten this so that it integrates with the Discourse plugin system, instead of just overwriting things with a bunch of jquery. I think it should be safe to use it now.

A data-max-height attribute can be added to the background image to set the image’s max height. The image and the layout scale for mobile.

(Nukeador) #7

Is there an URL where we can see the plugin working?

(Simon Cossar) #8

No, at the moment my forum is private. Soon I will try to set up a public category on it that I can use for demos.

(Nukeador) #9

It would be great if you could set this blog view as homepage too :smiley:


You, @Simon_Cossar, maintain two similiar plugins:

Whats their difference?

(Simon Cossar) #11

I’m not going to be maintaining the curated-home-plugin. I really like it and think that something similar to it would be useful for creating a user-friendly homepage, but I think it will be too difficult and time-consuming for me to maintain. If anyone is interested in using the code, I have a version of it up on github. It is working, but has a few issues.

The blog-post plugin is much simpler. It really just adds a body-class for topics in a chosen category so that that category can be styled separately from the other topics. If it breaks with a Discourse update I should be able to easily fix it.


I don’t understand how to write blog posts. Can’t find any ‘New post’ or similar when I’m in a blog topic.

(Simon Cossar) #13

The plugin creates blog posts out of topics in a certain category. It defaults to ‘blog’, but you can change it in the plugin’s settings.

You then need to create that category in Discourse. Go to ‘Categories>New Category’ and create your chosen blog category. In my case I created the category ‘discover nanaimo’. Don’t use an old category where you have posts with replies - at the moment blog posts can’t handle replies.

To create a header image, upload an image (ideally at the start of your post) and give it the class header-image you can also set the image’s max height by giving it a data-max-height attribute. Here’s an example of how to create a header image:

<img src="//" width="690" height="460" class="header-image" data-max-height="500">

(Pad Pors) #15

how can you do this? “to set the blog view as homepage”.

(Nukeador) #16

You can’t, that why I said it would be great to have that possibility :slight_smile:

(shantilal matariya) #17

Hi Simon,

Can You help me to setup your plugins into my existing rails application.


(Marcos P) #18

@Simon_Cossar You have plans to make it work again someday? I did not get to test but it seems wonderful!

(Simon Cossar) #19

It’s hard to find the time to update it. I think it’s a lot more straightforward to use WordPress for this kind of thing, with the wp-discourse plugin.

(Marcos P) #20

i understand! thanks for reply!

(Simon Cossar) #21

Thanks to @smartwatchme for funding it, I’ve rewritten this plugin to work with recent versions of Discourse. It now allows you to configure which groups should be allowed to create ‘blog-posts’ (admins and moderators by default), and which categories blog posts should be allowed to be created in. Members of allowed groups can convert the first post in a topic from a regular post into a blog post by clicking on the ‘book’ icon that’s found in the hidden (’…’) post menu buttons.

The plugin converts the first image in a post into a header image. It also adds the css class blog-post to the body tag, and the css class blog-post-content to the cooked content of the first post. It comes with some default styles that are used to style the first post in a topic separately from the replies.

The default styles can be disabled by deselecting the plugin setting the blog post use default styles setting. This could be useful if you only wish to use the header-image functionality of the plugin. See the plugin’s README for more details.

Pull requests, especially for improving the default styles, are welcome.