Opening a reply window 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개의 좋아요

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

1개의 좋아요

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개의 좋아요

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개의 좋아요

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개의 좋아요

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개의 좋아요

Not sure about it seems very uncommon

3개의 좋아요

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

3개의 좋아요

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개의 좋아요

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

6개의 좋아요

지금 이것이 가능한가요?

우리도 이 기능을 보고 싶어요 :folded_hands: 아직 불가능하다면, 이를 가능하게 하려면 많은 추가 작업이 필요할까요?

커뮤니티 멤버 중에는 사고의 리더(thought leader)나 분야별 전문가(SME)로, YouTube 라이브 세션을 진행하는 분들이 있어요. 이런 세션은 Q&A에는 (최선을 다해도) 괜찮지만, 더 깊은 토론에는 정말로 적합하지 않아요.

사용자들이 기존 이벤트 토픽(우리가 이벤트 플러그인을 사용 중인 곳)에 질문을 게시하도록 유도하고, 답변 입력 창이 팝업으로 열리며, 질문하는 분들이 해당 SME의 토픽에 게시하도록 보장하고 싶어요.

많은 고객들에게 우리가 제공하는 큰 가치 중 하나는, 사용자가 더 깊은 토론에 참여할 수 있는 장소를 제공한다는 점이에요.

YouTube이나 FB 라이브를 진행할 때, 그것은 단순히 대화를 시작하는 것일 뿐이에요. Discourse는 대화를 계속하기 위한 완벽한 도구예요.

사람들이 클릭할 수 있는 직접적인 URL을 제공하고, 답변 대화 상자를 미리 열어두며, 일부 기본 텍스트를 미리 채워 넣는 방식으로 프로세스를 단순화할 수 있다면 정말로 큰 도움이 될 거예요!!

2개의 좋아요

저도 같은 생각입니다. 우리 커뮤니티에 정말 유용할 것 같아요.

1개의 좋아요

저는 인스턴스에서 이를 위해 간단한 테마 컴포넌트를 사용합니다. 아래는 제 코드에서 가져온 변형 버전으로, #reply 외에도 #upload(데스크톱에서 업로드 창을 여는 새 답변)와 #edit(위키 OP용)를 지원합니다.

setTimeout을 피하고 draftSequence를 올바르게 관리하는 것(topic.draft_sequence이 맞는지 의문입니다) 등 아직 다듬어야 할 부분이 있으며, 여기에서 최선의 관행이 무엇인지도 정확히 알지 못합니다. 그렇다고 해도 제 환경에서는 잘 작동하고 있습니다.

/t/[slug]/[id]#reply와 같은 형태로 어떤 주제(Topic)로 이동하더라도 빈 새 답변이 입력된 컴포저가 열립니다.

사전 입력된 텍스트가 필요하다면 composer.open에 전달하는 객체의 reply 속성을 설정하면 됩니다. 또한 해당 주제에 이미 초안이 있으면, 이 새 답변을 생성하기 전에 초안을 저장할지 삭제할지 묻게 됩니다 – 원하는 동작이 해당 초안을 이어서 작성하는 것이라면 draftSequence가 정확해야 합니다.

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

도움이 되길 바랍니다.

13개의 좋아요

이후 이 부분을 변경하거나 업데이트하셨나요? 정말 유용할 것 같습니다. 제 인스턴스에서 이를 사용할 수 있는 사례를 방금 찾았거든요:

배너 주제에 답글을 남길 수 있는 간편한 원클릭 방법을 제공하는 것

1개의 좋아요

제가 기억하는 유일한 변경 사항은 사용자가 이미 로그인하지 않은 경우 로그인 흐름을 강제하는 것이었습니다. 대략 다음과 같은 코드를 추가했죠:

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

현재도 제 커뮤니티에서 이 방식을 사용하여 React 앱에서 사용자를 Discourse의 특정 흐름(답글, 편집, 업로드 등)으로 직접 이동시키고 있습니다.

2개의 좋아요