(+ New topic) button on all pages

theme-component

(Joe) #1

A simple theme component to add the + New Topic button to the header. The button will show on every page - even inside topics.

Github repository link
https://github.com/hnb-ku/discourse-new-topic-button-theme-component

See it live on Theme Creator:
https://theme-creator.discourse.org/theme/Johani/ntb

Screenshots:

Desktop:

Mobile:

Installation:

Follow the official guide for theme installation:

Settings:

This component has 3 settings where you can choose the button icon, the button text, and whether or not to hide the default “New topic” button:

Credit

This is based on @techAPJ’s tutorial here:

And on @dalerka’s patch to make things work with newer versions of Discourse here:

I only put it all together and added the theme settings to make things simple.


Adding "+ New Topic" button on every page
How to create a new topic button with category and topic template
Tiles Image Gallery
3 things I badly want Discourse to have by default!
(Hakan) #3

When I click on the new topic link, it looks like I was on the main page while in the category. He does not automatically select the category itself.

the category I want to cover “Wiki”
but but the editor defaults to auto default category.


(Joe) #4

I agree @nothing the button should follow the default behaviour and pre-populate the category field with the appropriate category.

This is fixed now. Please update the theme.

While on category pages, the composer will match the category you’re on.

I also added a demo for the theme on Theme-Creator, check the OP


(Sam Saffron) #5

Note if you have a topic draft, head to a topic, reload, click new topic, you will remove the old draft, no easy way of fixing this now


(Hakan) #6

İts okey problem solved bro.


(Southpaw) #7

Hi @Johani,

Thank you for this component and for the update that assigns the new topic to the currently-viewed category.

Would you consider adding an additional theme setting to set a title attribute for the button?

Use case: Many of our users are not familiar with the concept of a peer to peer support model, and have expressed frustration at not knowing how to ask a question in our Community. They say they do not understand what “New Topic” means when all they want to do is ask a question. I’ve renamed this global instance of the button “Ask a question” but also like to title it with a friendly explanation that you’re publicly asking other users.

I have added the title manually, but have to add it again after each update. I can continue to do so, but thought I’d ask just in case this would also be useful to others.


(Joe) #8

You’re most welcome @Southpaw.

That’s probably a very common use case. So, like you suggested, I added a new setting for the button title.


It works like this:

  • it’s empty by default.
  • You can add whatever text you need.
  • If you choose to leave it empty, it will inherit its value from the the button text field.

Go ahead and update the theme and the new setting should be there right away.

Let me know if there’s anything else you need.


(Southpaw) #9

:zap: Wow, that was fast!

Thank you @Johani! It’s perfect! (Of course :smiley_cat:)


(Hakan) #10

Failed to compile desktop_theme stylesheet: Error: Undefined variable: “$New-topic-button-text”.
on line 346 of 25/common-scss-light-default.scss

@if $New_topic_button_text == ‘’ {
----^


(Joe) #11

Hi @nothing

I just tried to install the theme on v2.0.0.beta9 +151 and everything went ok. I would love to help but need more information to do so.


(Hakan) #12


(Joe) #13

Thank you.

First, you can use this to get back into the site:

your.site.com/?safe_mode=no_custom%2Cno_plugins%2Conly_official

You can then disable the theme. I don’t believe the theme is the main cause of the issue.

Do you use Discourse in Chinese by any chance? Do you have a color-scheme with a Chinese name?