Link di intestazione personalizzati

:discourse2: Summary Custom Header Links allows you to easily add custom text-based links to the header.
:eyeglasses: Preview Preview on Discourse Theme Creator
:hammer_and_wrench: Repository Link https://github.com/discourse/discourse-custom-header-links
:open_book: New to Discourse Themes? Beginner’s guide to using Discourse Themes

Install this theme component

Features

Desktop

Mobile

(due to very limited space I don’t recommend adding more than one link on mobiles)


Settings

Name Description
custom header links Custom links to be displayed in the header
links position Note that when links are displayed on the left, they’re automatically hidden while scrolling within topics to make room for the title

Adding links is straightforward. Every link needs 6 items. You enter comma delimited values in this order:

link text, link title, URL, view, target, hide on scroll

Link text: the text for the link.
Link title: the text that shows when the link is hovered.
URL: The path for the link (can be relative).
View: vdm = desktop and mobile, vdo = desktop only, vmo = mobile only.
Target: blank = opens in a new tab, self = opens in the same tab.
Hide on scroll: remove = hides the link when the title is expanded on topic pages keep = keeps the link visible even when the title is visible on topic pages.

If you’re not sure what hide on scroll does, here’s an example:

Most Liked and Privacy are set to keep and so they remain visible. The other links are set to remove, and so are hidden when the title expands in the header. This only affects topic pages.

Links position: This setting allows you to change the default layout so links will appear on the left near the logo instead of on the right. Note that when positioned to the left, links will automatically be hidden when scrolling within topics to make room for the topic title.


:discourse2: Hosted by us? Theme components are available to use on our Standard, Business, and Enterprise plans.

Last edited by @JammyDodger 2024-06-11T20:31:00Z

Check documentPerform check on document:
82 Mi Piace

don’t know if this has been suggested, tried reading back but couldn’t find it.

was thinking that maybe adding the ability to create “sub-links” thus creating the idea of a list that you could edit (text color, background hover etc.) to get results similar to what zoom has

8 Mi Piace

the links that have the arrow to the right like developer means that it has “sub-links”

1 Mi Piace

Is it possible to add some basic dropdown menu to an any item?

I couldn’t create a dropdown menu with “Custom header links”. It seems Zoom did that. I reviewed their dropdown menu via console, but I couldn’t figure out how they interfere with the html of this component for adding dropdown to any item.

Is there a way to add this dropdown to item? @Johani

<div id="dropdown">
  <a title="Zoom Developer Documentation" href="https://marketplace.zoom.us/docs" target="_blank">Developer</a>
  <span class="caret"></span>
  <div class="dropdown-content">
    <a title="Zoom API Docs" href="https://marketplace.zoom.us/docs/api-reference/introduction" target="_blank">API</a>
    <a title="Zoom SDK Docs" href="https://marketplace.zoom.us/docs/sdk/native-sdks/introduction" target="_blank">SDK</a>
    <a title="Zoom Developer Blog" href="https://medium.com/zoom-developer-blog" target="_blank">Blog</a>
    <a title="Zoom Developer Changelog" href="https://marketplace.zoom.us/docs/changelog" target="_blank">Changelog</a>
    <a title="Zoom Developer Survey" href="https://docs.google.com/forms/d/e/1FAIpQLSeJPLhNuxjtkxyyV276R8S_nYz99fpMbbS8VWkC8Hwi7-2Byg/viewform" target="_blank">Survey</a>
  </div>
</div>
5 Mi Piace

Has anyone run into any issues with links not opening when setting links position to “left”?

Links work on Preview but not when I apply it to a theme.
Right alined links work fine though.

1 Mi Piace

Hi! Thanks for creating this.
Is it possible to add an SVG before the text link? If so - how?

1 Mi Piace

Have you found a solution for this? I am look for the same solution.

6 Mi Piace

how can the title convert **formatting code** into actual formatting? also how about Font Awesome icons before the text?

2 Mi Piace

Could be possible to add a flag to show or hide links as specific groups of users?

3 Mi Piace

Is there a way this theme component can allow for dropdown navigation? That means, when I hover over a header link, it has sub-items that appear underneath it. I know that this can be done via html/css as shown here:

2 Mi Piace

Thank you for creating this component!
One question and potentially a feature request: can we show a specific link for a specific group?
For example, if a user is in group customers I’d like to show a link to the customer’s control panel, if a user is in group workers I’d like to add a link to a different panel.
I think this would be a very useful feature.
The group name could be the last (optional) parameter.

2 Mi Piace

Grazie per questo! L’ho appena trovato dopo aver provato vari altri banner e componenti. È esattamente quello di cui ho bisogno!

Una richiesta/suggerimento: possibilità di riordinare i link. Ne ho appena creati alcuni e mi sono reso conto che vorrei aggiungerne uno in cima. Ora dovrò copiarli e incollarli tutti manualmente, il che è in realtà piuttosto macchinoso poichÊ continuano a sincronizzarsi/aggiornare altre voci mentre li copio verso il basso.

Il trascinamento della selezione o i pulsanti su/giĂš sarebbero molto utili per gli utenti futuri (o per modifiche future).

4 Mi Piace

[quote=“Nick_Chomey, post:131, topic:90588”]
Drag and drop o pulsanti su/giĂš sarebbero molto utili per gli utenti futuri (o per modifiche future).
[/quote]Puoi già manipolare l’ordine molto facilmente con alcune righe di CSS poiché utilizziamo la proprietà flex.

Ad esempio:

  • Ordine predefinito
    image

  • Ordine personalizzato
    image

Esempio CSS:

.custom-header-links li {
  &:nth-child(1) {
    order: 3;
    background: red;
  }

  &:nth-child(2) {
    order: 1;
    background: green;
  }

  &:nth-child(3) {
    order: 2;
    background: yellow;
  }
}
5 Mi Piace

@Nick_Chomey Mi sono spesso trovato nella necessità di farlo, non solo per questo componente del tema ma per molti altri componenti del tema che utilizzano l’impostazione type: list. Avevo pianificato di inviare una richiesta di funzionalità prima, ma l’ho completamente dimenticata, ma dato che me l’hai ricordato, ne ho aggiunta una qui:

3 Mi Piace

@dax Grazie! Non avevo idea che fosse possibile!

@keegan sembra fantastico, speriamo che venga aggiunto prima o poi!

2 Mi Piace

Sto cercando la stessa soluzione, hai scoperto come hanno fatto?
Grazie!

1 Mi Piace

Ciao @Johani
Grazie per aver creato un componente cosĂŹ fantastico!

È possibile che un link sia visibile solo se l’utente ha effettuato l’accesso?
SarĂ  un link esterno.

1 Mi Piace

Ciao @andreas_can benvenuto in Meta :wave:

Questo componente aggiunge una classe CSS a ciascun link in base al suo testo. La classe aggiunta è la stessa del testo che assegni al link, tranne per il fatto che gli spazi vengono sostituiti da un trattino (-) e il testo viene impostato in minuscolo. Quindi, alla fine viene aggiunta la stringa -custom-header-links.

Quindi, se aggiungi un link con il testo

privacy

allora l’elemento del link avrà la classe

privacy-custom-header-links

Se il testo del tuo link è

Visit Shop

allora la classe CSS sarebbe

visit-shop-custom-header-links

Quindi, ora conosci la classe aggiunta a ciascun link. Tornando alla tua domanda.

Discourse aggiunge una classe CSS al tag <HTML> quando l’utente non è connesso. Quella classe è

anon

Quindi, puoi usarla per nascondere determinati link agli utenti che non sono connessi. Diciamo che ho un link con il testo

Customer Support

e non voglio che venga mostrato agli utenti che non sono connessi.

Aggiungerei quindi questo CSS

.anon {
  .customer-support-custom-header-links {
    display: none;
  }
}

nella scheda common > CSS del mio tema principale.

Questo nasconderĂ  quel particolare link agli utenti che non sono connessi.

11 Mi Piace

Grazie per una risposta cosĂŹ rapida e completa!
È esattamente quello che stavo cercando.

Ci proverò :slightly_smiling_face:

3 Mi Piace

Nota che display: none; in CSS nasconde il link solo dal rendering del browser, ma è sempre completamente visibile a chiunque esamini il codice sorgente della pagina, ai crawler e ai motori di ricerca.

3 Mi Piace