Custom Header Links

This plugin is amazing – I’m not good at plugins, so don’t know how to branch off of it myself, but I feel that Discourse has a nice “simplicity” feel to it – it would be great to support images/icons.

Here is a ghetto way of how I achieved a Discord icon:

image

(Minus the color saturation – HDR screenshot bugs are the worst)

image

After installed, make a new CSS component, or edit the theme directly:

Here is what I used –


.headerLink
{
    color: white;
    
    &.d
    {
        background-image: url('https://i.imgur.com/MSef433.png');
        background-repeat: no-repeat;
        background-size: 22px;
        
        a
        {
            color: rgba(0, 0, 0, 0);
            text-decoration: none;
            &:hover
            {
                box-shadow: 0px 2px lightgray;
            }
        }
    }
}

  • I had issues with hover effects, so a bottom box shadow on hover is the best I got, since these are images instead of unicode:

image

  • I named the above example d because you have to name it something. I make the font 0 opacity, so it gets hidden, but d allows me to utilize the d class.

  • Is there a way to do this? Probably. But this is the ghetto way to bring about ideas until something better reveals itself :slight_smile:

1 Like

First of all this is a theme component, not a plugin. It is better to specify this before users get confused and try to install it like a plugin.

The second thing is, why you use this theme component instead of Iconified Header Links which serves the purpose of adding icons to the menu? :open_mouth:

6 Likes

Heck, that’s why I didn’t make a component – I’m still learning the terms.

Because it’s not cool enough to show up in that last of lazy-link-install components, I suppose ;D if the text links should be there, I wish the icons were there, too! It’s pretty awesome looking. Gonna check it out now.

EDIT: Works wonderfully.

3 Likes

It would be very nice to add another option other than vdm, vdo, vmo.

All of those mean that the header will appear at some point in the main task bar. It would be an excellent function, opening a whole new layer of functionality, if there was a 4th option so we could set menu items to only appear in the burger menu.

I suspect that’s a small tweak too :slight_smile:

To make sure what i’m saying is clear, i have pages like ‘team and partners’ which aren’t main menu items and should never appear in the main menu, but i would love for them to be in the burger menu along with other secondary menu links.

3 Likes

This works beautifully! It seems to disappear for me on an individual private messages page, though.

Replying to myself, this can be achieved using this plugin: Custom hamburger menu links

It seems defunct to have two plugins, when this one is already capable of putting menu links into the burger menu, and just needs a tiny tweak to unlock that functionality.

@Johani is that something you plan to add to this plugin? or is it better for those wanting to put menu links in the burger menu to build around your other plugin that i linked above?

2 Likes

I find the custom header links and burger links menus conflict with each other preventing admins from accessing the admin menu.

the use case we have, which i think is fairly common, is that we have a set number of links in the menu, yet on mobile there isn’t room for all of them. We resolve this by hiding some when the phone is held in portrait mode.

in this scenario a project like ours needs the ability to move some links into the menu when the phone is in portrait mode on a mobile (as we can do with the burger menu plugin). We also nee

1 Like

Great component.
Just what we were looking for: a way to show a simple menu with links to external pages and internal ones.

But we are having some trouble with it in mobiles. Is it a bug?
In a mobile -while displaying the forum in vertical view- there is no enough place for the menu and the standard buttons (search, site menu and user menu).
So the system hides that menus that are essential to forum navigation.

A user that is not connected cannot even connect, as he can not see the login button.

In horizontal view in the mobile everything seems to work OK.

If there is no place to put the header links, the component should show only the permanent (tagged as keep) ones and if there is no room either, just don’t show any link.
It is preferible to not showing the essential system menus.

Alternatively, if there is no room, the links could be displayed as a drop down list.

No, it is not that the links are note important, but impossible is impossible.
In the mobile in vertical position there is too few space, and the menu links are of less importance than the user menu, the hamburger itself or the login button.
So they should dissapear or be moved a a drop down list or the hamburger.

But in horizontal view there is enough space, so they should be showed.

Current implementation don’t let you decide to show them in other way in portrait mode or set different links in portrait or landscape mode in mobiles.

I’ve added a setting to this theme that allows the links to be displayed to the left as well. Due to the title position, these links are automatically hidden when scrolling within a topic.

8 Likes

I’m new to this. Added this, created my links, and the preview shows and works properly. However, in the live site the links don’t show up. I must be missing something. Can you help?

Have a look at the “Add theme components to a theme” section of How do I install a Theme or Theme Component?. It sounds like you might have missed that step.

3 Likes

Got it working. Thanks for that–I missed that last step of adding it to the theme.

Hi, is it possible to show the link only for users with a trustlevel greater then 1?

In a similar vein, is it possible to show a link only for users who are members of a particular group?

Our designer is having some problems with the responsive aspect of this (very nice and useful) add-on and she asks if she can change the breakpoint where it currently switches from the vdo to vmo elements?

Is this possible? Thanks

1 Like

Sure. Just fork and edit the theme component.

2 Likes

Thanks, I had a look but I don’t find it there… I guess it’s relying on some Discourse setting that applies throughout the site, not just for that menu?

Any way - we have it working with CSS media queries. Not ideal, but we can live with this.

1 Like

The switch from vdo - view desktop only - to vmo - view mobile only - is based on the user-agent in your browser and not on the width of the viewport you use / simulate.

CSS media queries are not as important in Discourse as they are in other sites that you might be accustomed to.

Discourse serves different optimized markup based on the device the user is on.

What I’m getting at is that you don’t need to worry much about CSS media queries. Your designer needs to either add ?mobile_view=1 to the URL they’re testing on, or use a mobile user-agent while testing / debugging things on desktop.

3 Likes

Interesting :thinking: thanks for taking the time to explain.

But when I am on desktop, playing with my browser window size, I see Discourse reacting and rearranging stuff on screen. That’s not coming from my user agent string, I assume. Is there another mechanism reacting to screen size?

For example: that time-lapse scroll bar on the right disappears at small widths and is replaced by a smaller indicator with just the post number and total like 19 / 24

1 Like