The only ones I’m aware of are mine and those made by @Alavi1412. It is relatively easy to adapt any existing Discourse widget or combination of widgets to work with this plugin.
I’m not sure what you mean?
Yeah. That’s just the custom html plugin. The issue is with the js in the script tag I included in the custom html, not with the custom html plugin or layouts plugin.
Still can’t reproduce this error . I’ve tried using just your profile widget and the custom html widget. The layouts admin works fine. Also, those logs seem unconnected to the layouts code. Have you tried rebuilding your container (i.e. ./launcher rebuild app)? Are you using the Discourse Master branch? What other plugins do you have installed?
I’ve updated the widget so that it works with the latest. And added some other minor fixes.
As it sounds like you’ve already read my previous explanation of how to do this and given it a shot, here’s some working methods with an explanation of what is going on. Add the methods to your version of the profile widget and see how you go.
First, let’s add a new button widget to the actions array, at the bottom of the html() method (before actions is pushed to contents).
Then add the createTopic method as a new method in the widget. I’ve added some comments to explain what’s going on. I’ve assumed that you want the button to work in both discovery (i.e. topic lists) and topic routes. This method is designed to work in both.
createTopic() {
// First we get the composer controller, as that is what we'll need
// to open the composer with. As we want to also check for existing
// drafts and the current discovery category, we'll also get the
// discovery controller.
const discoveryController = this.register.lookup('controller:discovery');
const composerController = this.register.lookup('controller:composer');
// I'm assuming the action you want to take is createTopic. The other
// actions you can take are listed at the top of the composer model.
let params = { action: 'createTopic' };
// Here we load the relevant composer params from the discovery controller
// (they may not exist though, e.g. if we loaded a topic directly)
const categoryId = discoveryController.get('category.id');
const draftKey = discoveryController.get('model.draft_key');
const draftSequence = discoveryController.get('model.draft_sequence');
// let's assign the topic if we're in a topic
const topic = this.attrs.topic;
// First we'll set the initial category in the compose category selector.
// You could set this to any category id you wanted. But let's set it
// to the topic category if we're in a topic and, failing that, the
// discovery category if there is one.
if (topic && topic.get('category')) {
params['categoryId'] = topic.get('category.id');
} else if (categoryId) {
params['categoryId'] = categoryId;
}
// if there is a draft new topic in discovery, load it, otherwise start
// a new one.
if (draftKey && draftSequence) {
params['draftKey'] = draftKey;
params['draftSequence'] = draftSequence;
} else {
params['draftKey'] = 'new_topic';
}
// Finally, let's open the composer with our params!
composerController.open(params);
},
Now we’ve got a New Topic button in the profile widget.
If you wanted a createTopic button that only works in discovery routes, that’s actually a lot simpler, as you just need to send createTopic to route:discovery and it will handle the rest. However, as you seem to be using the profile widget in both discovery and topic contexts, the above method will work in both.
That was incredibly kind of you to go thought that tutorial again! I read and went through the steps once again. And read the original instructions one more time, but still
I want to thank you regardless though. I will try to go through the instructions one or two more times and let you know what happens