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

:bookmark: تشرح هذه الوثائق كيفية إنشاء رابط يبدأ موضوعًا جديدًا في ديسكورس (Discourse) بمعلومات مملوءة مسبقًا.

:person_raising_hand: المستوى المطلوب للمستخدم: جميع المستخدمين

قد ترغب أحيانًا في تزويد المستخدمين برابط يفتح مُنشئ موضوع جديد بمعلومات مملوءة مسبقًا. قد يكون هذا مفيدًا لحالات استخدام مختلفة بما في ذلك قوالب تقارير الأخطاء، أو طلبات الميزات، أو المنشورات الموحدة.

بناء عنوان URL

عنوان URL الأساسي

لإنشاء موضوع جديد مملوء مسبقًا بدون معلومات إضافية، يمكنك إضافة /new-topic إلى عنوان URL الخاص بموقعك، كالتالي:

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

سيؤدي النقر على هذا الرابط إلى فتح مُنشئ موضوع جديد فارغ لأي مستخدم قام بتسجيل الدخول (إذا لم يكن مسجلاً للدخول، سيُطلب منك تسجيل الدخول/الاشتراك قبل فتح المُنشئ).

المعلمات الإضافية

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

للقيام بذلك، يمكنك إضافة معلمات إلى عنوان URL الأساسي:

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

سيؤدي هذا إلى فتح نافذة مُنشئ مملوءة مسبقًا بعنوان الموضوع والنص والفئة والوسوم.

بتقسيم الرابط / عنوان URL لإظهار الخيارات المتاحة، لدينا:

  • عنوان URL الأساسي: https://discourse.example.com/new-topic
  • عامل تشغيل ? في عنوان URL لإضافة الخيارات المختلفة
  • عنوان الموضوع: title=topic%20title
  • الرمز &، المستخدم في كل مرة يتم فيها تضمين معلمة أخرى
  • النص: body=topic%20body
  • الفئة والفئة الفرعية مفصولتان بشرطة مائلة / إذا كنت ترغب في تضمينهما: category=category/subcategory
  • الوسوم مفصولة بفاصلة (فواصل) , إذا كنت ترغب في تضمين وسوم متعددة: tags=email,planned

كل معلمة اختيارية ويمكن خلطها ومطابقتها اعتمادًا على النتيجة النهائية المطلوبة.

كبديل لاستخدام اسم الفئة/الفئة الفرعية، يمكنك تحديد category_id رقمي بدلاً من ذلك، مثل:

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

مثال

يمكنك تجربة هذا هنا على 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: على الرغم من ذلك، من فضلك لا تقم بإنشاء الموضوع فعليًا :slight_smile: للمزيد من الاستكشاف العملي للميزة، استخدم موقع العرض التجريبي الخاص بنا، try.discourse.org

استخدام أدوات المطور في المتصفح

افتح وحدة تحكم المتصفح (F12 → Console) واستخدم URLSearchParams المضمنة لبناء عنوان URL - حيث يتعامل مع جميع ترميزات النسبة المئوية تلقائيًا:

const base = 'https://discourse.example.com/new-topic';
const url = base + '?' + new URLSearchParams({
  title: 'My topic title',
  body: `Body text here...
supports multi line`,
  category: 'support',
  tags: 'bug,urgent'
});
console.log(url); // انسخ عنوان URL هذا

استخدام رابط مملوء مسبقًا مع الروابط المميزة

تدعم هذه الميزة أيضًا الروابط المميزة، بشرط عدم تضمين معلمة النص (body).

:information_source: يجب ترميز عنوان URL لكي يعمل الرابط.

على سبيل المثال، لإنشاء موضوع بعنوان URL التالي https://www.xkcd.com/556، سيكون الرابط:

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

أفضل الممارسات

  • مرجع ترميز URL لـ HTML الخاص بـ w3Schools هو مصدر جيد للعثور على ترميز أحرف النص في عنوان URL. إذا كان لديك الكثير من النصوص لإضافتها، فهناك أيضًا محول نص إلى عنوان URL في قسم “جربه بنفسك”.
  • قم دائمًا بترميز المعلمات لتجنب المشاكل مع الأحرف الخاصة.
  • إذا لم تكن متأكدًا من مُعرّف الفئة، يمكنك التحقق منه بالنظر إلى الرقم الموجود في رابط الفئة. (على سبيل المثال، https://meta.discourse.org/c/documentation/using-discourse/126)
  • اختبر الروابط المملوءة مسبقًا للتأكد من أنها تعمل كما هو متوقع.

:information_source: ليس من الممكن حاليًا الحصول على رابط مملوء مسبقًا يفتح مُنشئًا للرد على موضوع معين.

موارد إضافية

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}')

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

5 إعجابات

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

6 إعجابات

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

4 إعجابات

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