Adding to plugin-outlets using a theme

you can use Discourse.User.current() in your conditions. :smile_cat:

How can insert two icons?

Thanks a lot! Could you show me how an example code would look like with this condition? My programming skills are very modest. Cheers!

1 Like

https://github.com/discourse/discourse/blob/tests-passed/app/assets/javascripts/discourse/controllers/header.js.es6#L17-L19

Here you go :smile:

2 Likes

Sorry, I meant in the </head> section context. Is there something like

<script type='text/x-handlebars' data-template-name='/connectors/header-after-home-logo/add-header-links'>
  if user logged in
       <a class="nav-link " href="http://google.com" target="_blank">My Site</a>
  if user not logged in
       <a class="nav-link " href="http://google.com" target="_blank">Your Site</a>
</script>

Thanks so much!

1 Like
<script type='text/x-handlebars' data-template-name='/connectors/header-after-home-logo/add-header-links'>
  {{#if currentUser}}
     <a class="nav-link " href="http://google.com" target="_blank">My Site</a>
  {{else}}
     <a class="nav-link " href="http://google.com" target="_blank">Your Site</a>
  {{/if}}
</script>

Try this :smile:

7 Likes

Sorry to bother you again: Ist there a way to differentiate between members of groups, as in “A member of group X sees HTML 1, member of group Y sees HTML 2 …”?

1 Like

Does anyone know how I would pull a custom user field? Tried using the following code from the user.hbs template but cant seem to pull the custom user fields.

<script type='text/x-handlebars' data-template-name='/connectors/user-card-post-names/gamertags'>
            {{#if publicUserFields}}
              <div class="public-user-fields">
                {{#each uf in publicUserFields}}
                  {{#if uf.value}}
                    <div class="public-user-field">
                      <span class="user-field-name">{{uf.field.name}}</span>:
                      <span class="user-field-value">{{uf.value}}</span>
                    </div>
                  {{/if}}
                {{/each}}
              </div>
            {{/if}}
</script>

I have also tried using custom.user_field_1 at the field name as well. No Dice.

Edit: I know there is data here, as I am setting them with SSO and they do show up on the users profile. Trying to get them to show on the usercard as well.

I have this same question.

Does anyone know how to validate group membership in a template condition?

1 Like

If the data I want to pull is in another controller (UserController) from the one I want the data to display (UserCardController). Can I do this all within the site customization screen, or would I need to create a plugin and extend the UserCardController to include the data from UserController? What would would be the best way to pull it?

Thanks

What if the user had never visited the UserController? The card can be shown in many places.

What is the piece of data you want to pull?

I want to pull the publicUserField array that is created in userController. I am guessing if they never visited userController then I would need to create the array myself.

Yeah part of that field can be generated anywhere (the information about custom fields is in our Site object) but the other part requires the user_fields values which you’d have to make sure are available on the card somehow. I am not sure off the top of my head when the user card loads in the data that such fields are present.

3 Likes

does anyone know how to put an icon next to the search button?

1 Like

Looks like header-before-notifications is what you’re looking for

<ul role="navigation" class="icons clearfix">
  <div class="ember-view header-before-notifications-outlet mitt-show-header-before-notifications" id="ember1203">
    <div class="mitt-outlet-location">
      <i class="fa fa-plug"></i>
      header-before-notifications plugin outlet
    </div>
  </div>
  
  <li class="ember-view header-dropdown-toggle" id="ember1153">
    <a id="search-button" 
    aria-label="search topics, posts, users, or categories" 
    title="search topics, posts, users, or categories" 
    href="/search" data-ember-action="1206" class="icon"> 
      <i class="fa fa-search"></i>
    </a>
  </li>  

the

    <div class="mitt-outlet-location">
      <i class="fa fa-plug"></i>
      header-before-notifications plugin outlet
    </div>

was added by my plugin but you could have whatever there inside the <div class="ember-view header-before-notifications-outlet div

2 Likes

thanks :slight_smile:

it worked like this:

<script type='text/x-handlebars' data-template-name='/connectors/header-before-notifications/create-new-topic'>

Thank you for sharing nice tip. Do you think is suitable for “about” page?

@Tom_Newsom

I’m unable to get this to work. Do you have to install a plugin first?

I have this in </head>:

<script type='text/x-handlebars' data-template-name='/connectors/header-before-notifications/home-page-link'>
    <a class="icon" href="http://example.com/" title="visit our home page"><i class="fa fa-home"></i></a>
</script>

and this in CSS:

.home-page-link {
    float: left;
}
.home-page-link .fa-home {
    padding: 0;
}
.d-header .icons .unread-private-messages {
    left: 122px;
}
.d-header .icons .flagged-posts {
    left: 80px;
}

Is there anything else I have to do?

Since the header migration to VDOM this isn’t possible anymore.

The new way is this:

3 Likes

Is there a post or other documentation that lists the various locations eligible for widget injection? For instance, the post you linked mentions home-logo but I don’t see that anywhere in the rendered site. How/where do I find that in ember or learn more about using that approach to inject links/content?

1 Like