新しいトピックを事前に入力された情報で開始するためのリンクを作成する

:bookmark: このドキュメントでは、新しいトピックを投稿するために事前に入力された情報を持つリンクを作成する方法について説明します。

:person_raising_hand: 必要なユーザーレベル: すべてのユーザー

場合によっては、特定の情報が事前に入力された状態で新しいトピック作成ウィンドウを開くリンクをユーザーに提供したいことがあります。これは、バグレポートのテンプレート、機能リクエスト、標準化された投稿など、さまざまなユースケースで役立ちます。

URLの構成

ベースURL

追加情報なしで事前入力された新しいトピックを作成するには、サイトのURLに /new-topic を追加します。次のとおりです。

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
  • パラメータをもう1つ含めるたびに使用される &
  • 本文: 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をコピー

事前入力されたURLを特集リンクで使用する

この機能は、body パラメータが含まれていない場合に限り、特集リンクもサポートしています。

:information_source: リンクが機能するには、URLをURLエンコードする必要があります。

たとえば、次のURL https://www.xkcd.com/556 を持つトピックを作成する場合、リンクは次のようになります。

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

ベストプラクティス

  • w3Schools の HTML URLエンコーディングリファレンス は、テキスト文字がURLでどのようにエンコードされるかを確認するための良いリソースです。多くのテキストを追加する場合は、「Try It Yourself」セクションにテキストからURLへのコンバーターもあります。
  • 特殊文字に関する問題を回避するため、常にパラメータをURLエンコードしてください。
  • カテゴリIDが不明な場合は、カテゴリ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