إنشاء رابط لبدء موضوع جديد مع معلومات مُعبأة مسبقًا

:bookmark: This documentation explains how to create a link that starts a new topic in Discourse with pre-filled information.

:person_raising_hand: Required user level: All users

Sometimes you may want to provide users with a link that opens a new topic composer with certain information pre-filled. This can be useful for various use cases including bug report templates, feature requests, or standardized posts.

Constructing the URL

Base URL

To compose a new pre-filled topic with no extra information, you append /new-topic to your site URL, like so:

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

Clicking on this will open up a blank new topic composer for any logged-in user (if not logged-in, you’ll be prompted to signin/signup before then opening the composer).

Additional Parameters

While a link to open a blank composer can sometimes be useful, the main strength of this feature is the ability to pre-fill the composer with extra information.

To do this, you can add parameters to the base URL:

https://discourse.example.com/new-topic?title=topic%20title&body=topic%20body&category=category/subcategory&tags=email,planned

This will open a composer window pre-filled with topic title, body, category and tags.

Breaking down the link / URL to show the available options, we have:

  • Base URL: https://discourse.example.com/new-topic
  • The ? URL operator to add the different options
  • Topic title: title=topic%20title
  • The &, used each time when including another parameter
  • Body: body=topic%20body
  • The category and subcategory separated by a slash / if you want to include them: category=category/subcategory
  • The tags separated by comma(s) , if you want to include multiple tags: tags=email,planned

Each of the parameters is optional and can be mix and matched depending on your desired end result.

As an alternative to using the category/subcategory name, you can specify a numeric category_id instead, like:

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

Example

You can try this here on Meta:

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

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

:exclamation: Though please don’t actually create the topic :slight_smile: For a more hands-on explore of the feature use our demo site, try.discourse.org

Using a pre-filled URL with Featured Links

This feature also supports Featured Links, provided that the body parameter is not also included.

:information_source: The URL must be URL encoded for the link to work.

For example, to create a topic with the following URL https://www.xkcd.com/556, the link will be:

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

Best Practices

  • w3Schools HTML URL Encoding Reference is a good resource to find what text characters are encoded as in the URL. If you have a lot of text to add, there is also a text-to-URL converter in the ‘Try It Yourself’ section.
  • Always URL encode the parameters to avoid issues with special characters.
  • If you’re unsure about the category ID, you can check it by looking at the number in the category URL. (eg. https://meta.discourse.org/c/documentation/using-discourse/126)
  • Test the pre-filled links to ensure they work as expected.

:information_source: It is not currently possibly to have a pre-filled link that opens a composer to reply to a specific topic.

Additional Resources

89 إعجابًا
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

هناك الكثير من العمل التقني الشاق الذي يحدث هنا مما يجعله غير مقبول قليلاً للبشر؛ أراهن أننا نستطيع إنشاء صفحة ويب “مساعدة” تسمح للناس بإنشاء هذه الروابط بسهولة.

ما يعادل هذا قد يكون مشروعًا صغيرًا رائعًا لشخص ما لتنفيذه:

import urllib

site = 'meta.discourse.org'
title = '''My special checklist'''
category = 'todo'
tags = ['tag1', 'tag2']

template = '''\
# Important!

Do these things:

[ ] thing one
[ ] thing two
'''

query = urllib.parse.urlencode(dict(
    title =    title,
    category = category,
    tags =     ','.join(tags),
    body =     template,
))
print(f'https://{site}/new-topic?{query}')

يطبع هذا الرابط

4 إعجابات

محتمل* - اعتقدت أن المستندات عبارة عن ويكي :thinking:

إعجابَين (2)

تم تغيير هذا

3 إعجابات

شكرا على الفكرة! لقد ألهمتني لإنشاء Prefilled composer link generator

5 إعجابات

رائع! هذه فكرة تنفيذ رائعة. أحسنت صنعًا!

4 إعجابات

سؤال.

لقد قمت بتنفيذ مكون سمة، يحتوي على زر، انقر لفتح نموذج إنشاء موضوع جديد بمحتوى وعنوان مملوءين مسبقًا. مثل هذا

https://www.mydomain.com/new-topic?title=${title}&body=${body}

إنه يعمل بشكل جيد، يفتح نموذج إنشاء موضوع جديد، ولكن إذا لم أرغب في المتابعة، أنقر على “تجاهل” (Discard)
هذا لا يتجاهل الموضوع، بل يحفظه كمسودة بدلاً من ذلك… بما أنني نقرت على “تجاهل”، لا أريد أن يكون كمسودة، يجب عليّ تنظيف المسودات لاحقًا

أتساءل عما إذا كان هذا متوقعًا عند استخدام عنوان URL لإنشاء موضوع جديد هذا؟
هل هناك طريقة لعدم حفظه كمسودة إذا اخترت تجاهله.

شكراً.

كيفية التكرار:

  1. في مكون سمة، أضف زرًا، يتم تعيين مرجعه إلى عنوان URL لإنشاء موضوع جديد كما يلي
const topicBody = `.....`;
const title = "....";

// عنوان URL لإنشاء موضوع جديد
const createTopicUrl = `https://www.mydomain.com/new-topic?title=${title}&body=${topicBody}`;

const createTopicLink = `<span><a href="${createTopicUrl}" rel="noopener noreferrer">new topic</a></span>`;

const meta = `<div>${publisher}${pub_date} ${createTopicLink}</div>`;

const description = `<p>${description}</p>`;

// أضف زر "موضوع جديد" إلى واجهة المستخدم
return `<li class="news-item"><hr>
<div class="news-title"><a href="${url}" target="_blank">${title}</a></div>${meta}${description}</li>`;
  1. انقر على زر “موضوع جديد”، وشاهد نموذج الموضوع الجديد مفتوحًا بعنوان ومحتوى مملوءين مسبقًا.
  2. انقر على تجاهل (Discard)، وقم بالتأكيد
  3. تحقق من “مشاركاتي”، فإنه يحتوي على مسودة جديدة لهذا الموضوع الذي تم تجاهله..

لا يبدو أنني أستطيع تكرار هذا هنا على ميتا. هل يحدث هذا في الوضع الآمن؟ ما هو إصدار مثيلك؟ شكرًا لك.

إصدار نسختي هو 2026.1.0

باستخدام تجربة النظام المضمنة لإنشاء موضوع جديد، إذا تم التخلص منه، فلن يتم حفظه كمسودة.

حالتي هي، ربطت عنوان URL للموضوع الجديد بزر مضاف في مكون سمة.
لست متأكدًا من سبب اختلافه عن التجربة المضمنة…

إعجاب واحد (1)

مرحباً يا نيت،
شرح لي كوبايلوت هذا أدناه،
إذا كان هذا صحيحًا، أتساءل عما إذا كان يمكننا الحصول على وسيطة في عنوان URL لمنع ذلك، سيكون ذلك رائعًا
قل &auto_save=false
شكرًا لمساعدتك.

نعم، هذا متوقع في ديسكورس (Discourse). إن فتح المؤلف عبر عنوان URL للموضوع الجديد (مع عنوان/نص محدد مسبقًا) ينشئ مسودة بمجرد تهيئة المؤلف. حتى إذا نقرت على “تجاهل” وأكدت، فقد يحتفظ ديسكورس (Discourse) بإدخال مسودة لهذا المسار حتى يمكن استعادة المحتوى لاحقًا. يأتي هذا السلوك من منطق الحفظ التلقائي للمسودة/المؤلف الأساسي، وليس من تنسيق عنوان URL الخاص بك.

إذا كنت ترغب في تجنب المسودات، فستحتاج إلى نهج مخصص (على سبيل المثال، فتح نافذة منبثقة، أو النسخ إلى الحافظة، أو استدعاء واجهة برمجة تطبيقات المؤلف مع تجاوزات مفتاح المسودة)، ولكن عنوان URL للموضوع الجديد العادي سيشغل دائمًا الحفظ التلقائي للمسودة.

لست متأكدًا مما إذا كان هذا دقيقًا :person_shrugging:. لا يمكنني إعادة إنتاج هذا في الوضع الآمن هنا على ميتا. أعتقد أنك تستخدم الإصدار المستقر/ESR لمنتدىك؟