Custom Components -- add button or text at any plugin outlet

Install this theme component

Add a link button or arbitrary text at any plugin outlet. (Ignore the watermarks in the images–I took these screenshots on a staging/test site.)

I started developing this plugin for someone who wanted to display a “click this button to subscribe so that you can send PMs” button on user profiles and user cards. They wanted the button to display if the user couldn’t send PMs. Because I’m not always as clever as I’d like to think, I wrote the component using groups to determine whether the button was displayed. One problem with this approach was that staff members weren’t in the subscriber group, so they’d get the “you gotta subscribe” button even though they could send PMs. Also, the group was hidden, so it was impossible to use it in a theme component anyway. I re-wrote that theme component to use currentUser.can_send_private_messages to determine whether to display the button.

Who is this for?

If you want to put a button with a link in it, or some arbitrary text that is displayed or hidden for certain groups, this will let you insert them at any plugin outlet. You want to add a “You outa subscribe” link button between every message except for those who aren’t members? This will do it. You want to stick some arbitrary HTML at a plugin outlet, just to see what it’ll look like? This will do that.

How it helps developers

This theme has some simple examples of how to:

but if you’re trying to do it inside of a <template> inside of a .gjs file, it works a little differently (like {{htmlSafe component.text}})

15 Likes

Space makes the text not bold.


Great component!

5 Likes

Would it be possible to add placeholders to the Button URLs, e.g. for the URL to contain the topic ID in which the user is located?

I’m not quite sure. If you’ve got a budget, I’ll take a look.

What would your button do if it had the topic id?

If you figure it out and want to make a PR, I’ll probably accept it.

I’m pretty sure that the answer is no, but that you could use the workaround described here

2 Likes

Hi @pfaffman

We want to add such a set of buttons to every topic for members in our business account user group.
The button would then trigger creating a new PM which then includes the current URL the user is on

That way our business customers can send us request to pin, highlight or “sponsor” speficic topics

As you know, you can create a URL that will open a new topic composer. You could make that be the link added by the theme component.

I don’t think that it’s possible to do that without adding code to the theme component (but maybe it is?). Maybe someone has an idea about that and will offer that solution here (or on the other topic). If not, you can contact me or post in Marketplace with the description of what you need and a budget.

2 Likes