Dynamic Templates for plugin-outlet UIs

AI-generated summary

In a discussion about extending the Discourse UI with dynamic templates for plugin-outlets, mandarbapaye asked how to access the Ember controller backing the above-site-header outlet to display user-specific content. eviltrout clarified that as of the latest stable release, outlets cannot access controller methods directly. Instead, he recommended using a connector class or creating a new Ember component, both of which provide access to this.currentUser. He further noted that user data, such as the username, can be accessed directly in the template using {{currentUser.username}}. mandarbapaye thanked eviltrout for the guidance and indicated they would explore the connector class approach.

Hi All

I am trying to extend the discourse UI by leveraging the plugin-outlets. Currently trying to add a custom header on top of the discourse header by leveraging ‘above-site-header’ plugin-outlet. I would like to make this template dynamic based on the logged in user. I am not able to figure out which ember controller backs up the plugin-outlet templates. I would really appreciate if someone could point me in the right direction on this one. (I tried ApplicationController as the outlet sits in application.hbs, but no luck).

Thanks
Mandar

As of our latest stable release, outlets can only receive access to the parameters passed into them, so you can’t access controller methods.

Instead you should use a connector class for your outlet. Additionally, you could just create a new ember component and use it in your connector – it should have this.currentUser to know about the current person who is logged in.

Taking it a step further, just in your template you should be able to say {{currentUser.username}} and find out things about your user in there too.

Hi Robin - Thanks so much for the quick reply. I will checkout the connector class.

Regards
Mandar