Ouvrir une fenêtre de réponse via 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 « J'aime »

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

1 « J'aime »

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 « J'aime »

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 « J'aime »

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 « J'aime »

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 « J'aime »

Not sure about it seems very uncommon

3 « J'aime »

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

3 « J'aime »

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 « J'aime »

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

6 « J'aime »

Is this possible now?

We would love to see this feature as well :pray: Would it take a lot of extra work to make this possible, if it’s not already?

Some of our community members are thought leaders or SMEs that run YouTube Live sessions, which is okay (at best) for Q&A and turrrrrible for deeper discussion.

We want to be able to direct users to post their questions to an existing Event Topic (where we’ve used the events plugin) and have the reply window pop up, and ensure that the folks with the questions are posting to the respective SMEs topic.

One of our big value adds to a lot of the folks we’re working with is that we provide a place where they can engage with their users in deeper discussion.

When they do a YouTube or FB live, they are merely STARTING the conversation. Discourse is the perfect tool to CONTINUE the conversation.

If we could simplify the process by having giving a direct URL that people can click, and we can pre-open the reply dialog box, and pre-fill it with some boilerplate text, that would be so helpful!!

2 « J'aime »

Moi aussi. Ce serait super utile pour notre communauté.

1 « J'aime »

J’utilise pour cela un composant de thème simple dans mon instance. Voici une adaptation de la mienne, qui accepte également #upload (une nouvelle réponse ouvrant la fenêtre de téléchargement sur le bureau) et #edit (pour les OP de wiki), en plus de #reply.

Il nécessite quelques améliorations, comme éviter setTimeout et gérer correctement draftSequence (je ne pense pas que topic.draft_sequence soit correct), et je ne sais pas quelle serait la meilleure pratique ici. Cela dit, cela fonctionne bien pour moi.

La navigation vers n’importe quel sujet comme /t/[slug]/[id]#reply ouvrira le compositeur avec une nouvelle réponse vide.

Si vous avez besoin d’un texte prérempli, c’est possible en définissant l’attribut reply sur l’objet passé à composer.open. De plus, s’il existe déjà un brouillon pour ce sujet, il vous demandera si vous souhaitez le sauvegarder ou l’abandonner avant de créer cette nouvelle réponse. draftSequence doit être correct si le comportement souhaité est de reprendre ce brouillon.

<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>

J’espère que cela vous aidera.

13 « J'aime »

Avez-vous modifié / mis à jour cela depuis ? Ce serait vraiment utile - je viens de trouver un cas d’utilisation pour cela dans mon instance :

donner aux gens un moyen simple en un clic de répondre à un sujet de bannière.

1 « J'aime »

Le seul changement dont je me souvienne est l’application du flux de connexion si l’utilisateur n’est pas déjà connecté, quelque chose comme :

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

Je l’utilise toujours dans ma communauté pour amener les utilisateurs de mon application React directement à certains de ces flux sur Discourse (répondre, modifier, télécharger, etc.).

2 « J'aime »