Creare un link per avviare un nuovo argomento con informazioni precompilate

:bookmark: Questa documentazione spiega come creare un link che avvia un nuovo argomento in Discourse con informazioni precompilate.

:person_raising_hand: Livello utente richiesto: Tutti gli utenti

A volte potresti voler fornire agli utenti un link che apra un nuovo compositore di argomenti con alcune informazioni precompilate. Questo può essere utile per vari casi d’uso, inclusi modelli di segnalazione di bug, richieste di funzionalità o post standardizzati.

Costruire l’URL

URL di base

Per comporre un nuovo argomento precompilato senza informazioni aggiuntive, aggiungi /new-topic all’URL del tuo sito, così:

https://discourse.example.com/new-topic

Cliccando su questo si aprirà un compositore di nuovo argomento vuoto per qualsiasi utente autenticato (se non si è autenticati, verrà richiesto di accedere/registrarsi prima di aprire il compositore).

Parametri aggiuntivi

Sebbene un link per aprire un compositore vuoto possa talvolta essere utile, la forza principale di questa funzionalità è la capacità di precompilare il compositore con informazioni aggiuntive.

Per fare ciò, puoi aggiungere parametri all’URL di base:

https://discourse.example.com/new-topic?title=titolo%20argomento&body=corpo%20argomento&category=categoria/sottocategoria&tags=email,planned

Questo aprirà una finestra del compositore precompilata con titolo dell’argomento, corpo, categoria e tag.

Analizzando il link/URL per mostrare le opzioni disponibili, abbiamo:

  • URL di base: https://discourse.example.com/new-topic
  • L’operatore URL ? per aggiungere le diverse opzioni
  • Titolo argomento: title=titolo%20argomento
  • Il carattere &, usato ogni volta che si include un altro parametro
  • Corpo: body=corpo%20argomento
  • La categoria e la sottocategoria separate da uno slash / se si desidera includerle: category=categoria/sottocategoria
  • I tag separati da virgola(e) , se si desidera includere più tag: tags=email,planned

Ciascuno dei parametri è facoltativo e può essere combinato a seconda del risultato finale desiderato.

Come alternativa all’uso del nome della categoria/sottocategoria, puoi specificare un category_id numerico invece, come:

https://meta.discourse.org/new-topic?title=titolo%20argomento&category_id=3

Esempio

Puoi provarlo qui su Meta:

https://meta.discourse.org/new-topic?title=titolo%20argomento&body=corpo%20argomento&category=support/wordpress&tags=wordpress

https://meta.discourse.org/new-topic?title=titolo%20argomento&body=corpo%20argomento&category=support/wordpress&tags=wordpress

:exclamation: Tuttavia, per favore non creare effettivamente l’argomento :slight_smile: Per un’esplorazione più pratica della funzionalità, usa il nostro sito demo, try.discourse.org

Utilizzo degli strumenti per sviluppatori del browser

Apri la console del browser (F12 → Console) e utilizza URLSearchParams integrato per costruire l’URL — gestisce automaticamente tutta la codifica percentuale (percent-encoding):

const base = 'https://discourse.example.com/new-topic';
const url = base + '?' + new URLSearchParams({
  title: 'My topic title',
  body: `Body text here...
supports multi line`,
  category: 'support',
  tags: 'bug,urgent'
});
console.log(url); // copia questo url

Utilizzo di un URL precompilato con Collegamenti in Evidenza (Featured Links)

Questa funzionalità supporta anche i Featured Links, a condizione che venga omesso anche il parametro body.

:information_source: L’URL deve essere codificato per l’URL affinché il link funzioni.

Ad esempio, per creare un argomento con il seguente URL https://www.xkcd.com/556, il link sarà:

https://meta.discourse.org/new-topic?title=https%3A%2F%2Fwww.xkcd.com%2F556

Best Practice

  • La Riferimento alla codifica URL HTML di w3Schools è una buona risorsa per scoprire come vengono codificati i caratteri di testo nell’URL. Se devi aggiungere molto testo, c’è anche un convertitore da testo a URL nella sezione ‘Try It Yourself’.
  • Codifica sempre in URL i parametri per evitare problemi con caratteri speciali.
  • Se non sei sicuro dell’ID della categoria, puoi verificarlo guardando il numero nell’URL della categoria. (es. https://meta.discourse.org/c/documentation/using-discourse/126)
  • Testa i link precompilati per assicurarti che funzionino come previsto.

:information_source: Al momento non è possibile avere un link precompilato che apra un compositore per rispondere a un argomento specifico.

Risorse Aggiuntive

89 Mi Piace
Start creating a new topic via link?
Link that pre-populates the composer?
Fill in post for user?
What is the best way to integrate member applications?
Open Composer with Prefilled information
Unlisted categories
URL to set up new topic and category, tags
Problem in sso redirection for compose a new pre-filled topic via URL
Pre-filled topics don't recognize subcategories anymore
Topic-specific reply template
Rename @discobot's start new user command
Bookmarklet or chrome extension for posting links to a Discourse
Add one button for topic create with pre-filled content without composer or API?
How Coinbase Uses Discourse to Educate Customers and Improve SEO
Link to New Topic?
Link to create a new topic with parsed values in GET-method data?
[PAID] extra input fields for new topic
How to "replace" +New Topic with a custom button that brings up the composer
Discourse Templates
Create new topic via URL and set tag or category
Wording for private/secure categories
Topic-specific reply template
Topic-specific reply template
How to add a "button" which composes a pre-filled topic
Start a topic by pasting a link (like Reddit)
Link to start a topic with a pre-filled attachment file
How to create a post clicking a link?
Is there any link to open composer (for hyperlink)?
"push" sso users to discourse?
Post commits via webhook inside a topic as reply
Was this Article helpful? Yes or No
Gitter: Post notifications to chat, post transcripts to forum
How to make all users who sign up or accept in invite go to a specifed category(with post composer open)
Category-specific "new topic" email address/url in notification email?
Open new topic composer in a separate window
Onboarding: Discobot, automated messages, other options?
Deep link to new topic or account creation
Alerts that react to the user
Feedback form / reporting bugs
How to have a reply link with pre-filled information?
How do I create a link which opens Create Topic?
Create a link that will open the editor with a specific category and a specific tag
Any Direct URL To New Topic Page?
Creating pre-filled personal message links
URL for "Sign Up" or "Create Topic"?
Link to "Create new topic" and passing tag and category with query var?
Opening a reply window via URL
How do I create a link which opens Create Topic?
Opening a reply window via URL
Prefilled composer link generator
[Solved] In plugin: opening the composer without changing the route
URL to start new post
New Topic Create URL is not working for Subcategory
Create new topic in category with specific tag via URL
Is there a way to make an input form for structured data?
Placeholder Forms
Direct link to composing a comment?
Topic-specific reply template
Creating pre-filled personal message links
Oneboxing not working when starting a topic with pre-filled information
Using topic templates for categories
Impossible to copy heading links
Topic Templates
Have url for creating topic with specific title
Oneboxing not working when starting a topic with pre-filled information
Is there a way to link directly to the editing screen?
Directly linking to new-topic not working when default list filter = no sub categories
Chrome/Firefox extension "Share to discourse"
How to add%{post_url} in customize URL
How to auto set topic title?
How can I create a new topic in Discourse via a link or direct the person to the topic if it exists