Apertura di una finestra di risposta tramite URL

Hi All,

I know that we can create a new topic via url with special param.
But I want my users to click a link to reply a specific topic. Is there a way to add special params in the url query to auto open reply window for my users? If not, is there a way I can do this?

5 Mi Piace

Yes, @techapj added this a while ago, details are here:

1 Mi Piace

Hi Jeff,

Thank you for your reply, but what I want is that I want my users to reply
a topic which has already been created by others.
eg. I have a topic A in my forum, and I want every user click this link to
reply under topic A, not to create another topic.

What I want is when I open this link, the reply window popup, I want this
action equals to click the “reply” button under a topic.

1 Mi Piace

It has been a while and I haven’t found a way to do it.
I just want to be able to create a link that when clicked opens a specific topic with the reply box activated and with the focus on it.

Something like:
https://meta.discourse.org/t/how-to-open-reply-window-via-url/#reply

Anyone knows how can it be achieved?
Thanks,

2 Mi Piace

What I posted above works, but remember you don’t need to be on a specific topic to reply to it.

If your requirement is “must navigate to topic page, and then open the composer to reply”, then we don’t have that… but again it’s not required, you can reply to any topic from any other topic (or any location in the Discourse app, in fact) in the composer.

That post only mentions new-topic, where is the handy url to post a reply?

I believe there is one, cc @techAPJ

I’m aiming to use that link outside of Discourse. For example, putting a link on my blog, and when clicked it opens a new tab and starts a reply on a particular topic of the forum.

Is there a way to do it?

Thanks for your help.

Yes, the answer above works as you describe. Perhaps @techapj can help me explain because I seem to be failing at explaining this at the moment.

2 Mi Piace

The feature we have right now only supports creating new topic via URL.

What @magoz wants is to have a URL for an existing topic that will open composer and user can start replying on that topic as soon as they visit that URL. This is currently not available and is not on my list right now.

Should we add support for this feature?

8 Mi Piace

Not sure about it seems very uncommon

3 Mi Piace

My bad @magoz I was indeed misunderstanding. I could have sworn we had a pre-filled reply URL though.

3 Mi Piace

Apologies for my late reply.

Opening the composer (in a blank state) from an URL would be useful for those who have external websites working with Discourse and ask their users to reply to a particular Discourse topic.

For instance, I have a private website where I teach online lessons. I ask my students to reply to specific discourse topics to introduce themselves, to post their homework, etc.

It would be nice to be able to add something like ?reply at the end of any topic’s URL, and share that link with them.

For example:

<a href="https://meta.discourse.org/t/how-to-open-reply-window-via-url/44781?reply">link</a>

It would open a new reply to that topic with the composer open.

7 Mi Piace

I would love to see it, too. Including template-support for answers, so it’s not just for topics :slight_smile:

6 Mi Piace

È possibile farlo ora?

Ci piacerebbe molto vedere anche questa funzionalità :folded_hands: Sarebbe molto lavoro in più renderla possibile, se non lo è già?

Alcuni membri della nostra comunità sono leader di pensiero o esperti di settore (SME) che conducono sessioni YouTube Live, il che va bene (al massimo) per le domande e risposte, ma è terribile per discussioni più approfondite.

Vorremmo poter indirizzare gli utenti a pubblicare le loro domande in un Topic Evento esistente (dove abbiamo utilizzato il plugin Eventi), far apparire la finestra di risposta e garantire che le persone con le domande pubblichino nel rispettivo topic dell’esperto.

Uno dei nostri principali vantaggi per molte delle persone con cui collaboriamo è fornire un luogo dove possono impegnarsi in discussioni più approfondite con i loro utenti.

Quando fanno una diretta su YouTube o Facebook, stanno semplicemente INIZIANDO la conversazione. Discourse è lo strumento perfetto per CONTINUARE la conversazione.

Se potessimo semplificare il processo fornendo un URL diretto su cui le persone possono cliccare, aprendo automaticamente la finestra di dialogo per la risposta e pre-compilandola con un testo standard, sarebbe di grande aiuto!!

2 Mi Piace

Anche per noi. Sarebbe utilissimo per la nostra comunità.

1 Mi Piace

Nella mia istanza utilizzo per questo un componente tema semplice. Di seguito trovi una versione adattata dalla mia, che accetta anche #upload (una nuova risposta che apre la finestra di caricamento su desktop) e #edit (per gli OP delle wiki), oltre a #reply.

Ha bisogno di qualche ritocco, come evitare l’uso di setTimeout e gestire correttamente draftSequence (non credo che topic.draft_sequence sia corretto), e non so quale sia la migliore pratica in questo caso. Detto questo, per me funziona bene.

Navigando su qualsiasi argomento come /t/[slug]/[id]#reply si aprirà il compositore con una nuova risposta vuota.

Se hai bisogno di un testo precompilato, è possibile impostare l’attributo reply sull’oggetto passato a composer.open. Inoltre, se esiste già una bozza per quell’argomento, verrà chiesto se vuoi salvarla o scartarla prima di creare questa nuova risposta: draftSequence deve essere corretto se il comportamento desiderato è riprendere quella bozza.

<script type="text/discourse-plugin" version="0.4">
  if (/.*#reply$/g.test(document.URL)) {
    const { REPLY } = require('discourse/models/composer').default;
    
    const composer = Discourse.__container__.lookup('controller:composer');
    
    setTimeout(function() {
      const topic = Discourse.__container__.lookup("controller:topic").get("model");
      if (topic) {
        composer.open({
            action: REPLY,
            draftKey: topic.draft_key,
            draftSequence: topic.draft_sequence,
            topic,
        });
      }
    }, 0)
  }
</script>

Spero che questo possa esserti utile.

13 Mi Piace

Hai modificato / aggiornato questo da allora? Sarebbe davvero utile - ho appena trovato un caso d’uso per questo nella mia istanza:

dare alle persone un bel modo con un clic per rispondere a un argomento banner

1 Mi Piace

L’unica modifica che ricordo di aver apportato è stata l’applicazione del flusso di accesso se l’utente non è già connesso, qualcosa del tipo:

        if (!Discourse.User.current()) {
            Discourse.__container__.lookup("route:application").send("showLogin");
        }

Lo uso ancora nella mia community per portare gli utenti dalla mia app React direttamente ad alcuni di questi flussi su Discourse (rispondi, modifica, carica, ecc.).

2 Mi Piace