Abrir una ventana de respuesta a través de 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 Me gusta

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

1 me gusta

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

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

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

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

Not sure about it seems very uncommon

3 Me gusta

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

3 Me gusta

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

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

6 Me gusta

¿Es esto posible ahora?

Nos encantaría ver esta función también :folded_hands: ¿Requeriría mucho trabajo adicional hacerlo posible, si aún no lo es?

Algunos de los miembros de nuestra comunidad son líderes de opinión o expertos en la materia (SME) que realizan sesiones en vivo en YouTube, lo cual está bien (en el mejor de los casos) para sesiones de preguntas y respuestas, pero es terrible para discusiones más profundas.

Queremos poder dirigir a los usuarios a publicar sus preguntas en un Tema de Evento existente (donde hemos utilizado el plugin de eventos) y que se abra la ventana de respuesta, asegurando que las personas con preguntas publiquen en el tema correspondiente del experto.

Uno de nuestros principales valores agregados para muchas de las personas con las que trabajamos es que les ofrecemos un espacio donde pueden interactuar con sus usuarios en discusiones más profundas.

Cuando hacen un directo en YouTube o Facebook, simplemente están INICIANDO la conversación. Discourse es la herramienta perfecta para CONTINUAR la conversación.

Si pudiéramos simplificar el proceso proporcionando una URL directa que la gente pueda hacer clic, y que abra directamente el cuadro de diálogo de respuesta y lo prellene con un texto estándar, ¡sería de gran ayuda!!

2 Me gusta

Igual. Sería súper útil para nuestra comunidad.

1 me gusta

Uso un componente de tema sencillo para esto en mi instancia. A continuación, una adaptación de la mía, que también acepta #upload (una nueva respuesta que abre la ventana de carga en escritorio) y #edit (para los OP de wikis), además de #reply.

Necesita algunos ajustes, como evitar setTimeout y gestionar correctamente draftSequence (no creo que topic.draft_sequence sea lo adecuado), y no sé cuál sería la mejor práctica aquí. Dicho esto, me funciona bien.

Navegar a cualquier tema como /t/[slug]/[id]#reply abrirá el editor con una nueva respuesta vacía.

Si necesitas texto prellenado, es posible configurando el atributo reply en el objeto pasado a composer.open. Además, si ya existe un borrador para ese tema, preguntará si deseas guardarlo o descartarlo antes de crear esta nueva respuesta; draftSequence debe ser correcto si el comportamiento deseado es reanudar ese borrador.

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

Espero que esto ayude.

13 Me gusta

¿Has cambiado / actualizado esto desde entonces? Sería muy útil; acabo de encontrar un caso de uso para ello en mi instancia:

dar a la gente una forma agradable de hacer clic para responder a un tema de banner

1 me gusta

El único cambio que recuerdo haber hecho fue forzar el flujo de inicio de sesión si el usuario aún no ha iniciado sesión, algo como:

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

Todavía lo uso en mi comunidad para llevar a los usuarios de mi aplicación React directamente a algunos de estos flujos en Discourse (responder, editar, cargar, etc.).

2 Me gusta