I use the Memberful-Discourse integration.
I want to add a “billing” section right here :
In fact, when a user will click on billing, it will convert to the memberful account of the user. I will put a simple link to make it happen. I already have this link. I just want to know the code to add a section here.
Is it possible?
joebuhlig
(Joe Buhlig)
February 27, 2018, 12:10am
2
You could likely tie into the user-main-nav
connector and add it to the users profile. It’s not exactly the same placement but it would have roughly the same effect.
https://github.com/discourse/discourse/blob/8296f493ed5548698647d6890ca1d2e069630198/app/assets/javascripts/discourse/templates/user.hbs#L207
4 Likes
Ok interesting, can you tell me exactly what I have to do please?
joebuhlig
(Joe Buhlig)
February 27, 2018, 12:44am
4
Combine that plugin outlet with this:
Discourse includes hundreds of Plugin Outlets which can be used to inject new content or replace existing contend in the Discourse UI. ‘Outlet arguments’ are made available so that content can be customized based on the context.
Choosing an outlet
To find the name of a plugin outlet, search Discourse core for “<PluginOutlet”, or use the plugin outlet locations theme component. (e.g. topic-above-posts).
Wrapper outlets
Some outlets in core look like <PluginOutlet @name="foo" />. These allow …
4 Likes
{{plugin-outlet name="user-main-nav" tagName='' connectorTagName='li' args=(hash model=model)}}
What is the unique-id?
My code so far is this (what do I have to change?) :
<script type='text/x-handlebars' data-template-name='/connectors/user-main-nav/add-header-links'>
<a class="nav-link " href="https://lepeuplier.memberful.com/account" target="_blank">Facturation</a>
</script>
1 Like
joebuhlig
(Joe Buhlig)
February 27, 2018, 1:22am
6
I haven’t tested it but that looks good to me. The unique I’d is something you make up for the project.
5 Likes
It worked! Thanks so much!
6 Likes
I wrote a different code to make it appear at the place I want
<script type="text/discourse-plugin" version="0.8">
api.onPageChange(() =>{
addNav();
});
function addNav(){
if($('.affiliation-link').length){
// do nothing
} else {
li = '<li class="no-glyph nav-interface affiliation-link"><a href="https://lepeuplier.memberful.com/account">Facturation</a></li>';
$(".user-preferences-page .preferences-nav").append(li);
}
}
</script>
2 Likes