Custom Header Links

This component is great, but I believe it lacks an important feature: the ability to move a link to the hamburger menu when, on mobile, it is hidden from the header. Indeed, in most cases, I think removing the link entirely breaks the UI.

Because I urgently needed this feature, I did a fork:
https://github.com/sylque/discourse-custom-header-links2

However, I would love to see this in the official component.

You can see a demo here (check this page both on desktop and mobile).

4 Likes

Thank you for sharing your work @syl :+1:

The goals of this component are pretty clear, it allows you to add links to the header with as little work as possible. As such, there are no plans to move the desktop-only links to the hamburger menu on mobile.

We’re generally very careful not to introduce any breaking changes, so it’s definitely feasible for you to maintain a fork of the component, but it’s not something that I would recommend.

That said, if you’re OK with some links being in the hamburger menu on mobile, then it follows that said links are not of the utmost importance and wouldn’t need to be in the desktop header in the first place. Have you considered using the Custom hamburger menu links component for these links alongside this component?

Such a setup would allow to you add the most important links in the header, while keeping less important ones tucked away in the hamburger menu on both desktop and mobile.

6 Likes

This isn’t the end of the world but it would be good if text wrapping for topic titles (which is the default behaviour) kicked in when the text hits a header link, rather than the title becoming “…”

The behaviour is the same for the topic title in the header whether you have this component installed or not. Long titles are truncated and an ellipsis is added at the end.

We never wrap the topic title in the header because the header has a fixed height and there isn’t enough space to display a multiline title and the topic’s category and tag information on a third line below that.

Of course, when you add links with this component, you will by definition reduce the space left for the title to display in. The component gives you a lot of control over what links to keep visible in the header if you’re on a topic page and the title is visible in the header.

That bit is covered in the installation instruction in the OP under “Hide on scroll”.

7 Likes

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