Compose a new pre-filled topic via URL


(Arpit Jalan) #1

Discourse now supports composing a new (pre-filled) topic via URL! :sunny:

To compose a new pre-filled topic, modify URL params like this:

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

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

Try it out live, here on meta! :smile:

Also, instead of providing category/subcategory name, you can also specify category_id, like:

Note that if both category_id and category is passed as params, priority is given to category_id.

https://github.com/discourse/discourse/commit/cff6e49eb749acfe8d39e892d60ffed5ff9b94a9

This feature also supports “Start a topic by pasting a link (like Reddit)”, provided that the body is not present in paramater, for example:

https://meta.discourse.org/new-topic?title=https://www.xkcd.com/556

How to open composer with prefilled content?
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?
Pre-filled REPLY to an existing topic via URL
How to open reply window via URL
How to open reply window via URL
Creating new topic via url doesn't work
Add one button for topic create with pre-filled content without composer or API?
Using the Discourse API to post with uploaded files?
Bookmarklet or chrome extension for posting links to a Discourse
How to auto set topic title?
Title of topic does not resolve from a URL given to "title=" param when composing a topic via "/new-topic" API
How Coinbase Uses Discourse to Educate Customers and Improve SEO
Cannot compose a pre-filled topic via URL when subcategory has topic template
Is there a way to make an input form for structured data?
Cannot compose a pre-filled topic via URL when subcategory has topic template
Unlisted categories
How do I create a link which opens Create Topic?
Create new topic via URL and set tag or category
Composing a prefilled topic via url - tag parameter breaks it
How do I create a link which opens Create Topic?
Open new topic composer in a separate window
Gitter: Post notifications to chat, post transcripts to forum
Chrome/Firefox extension "Share to discourse"
Title of topic does not resolve from a URL given to "title=" param when composing a topic via "/new-topic" API
Wording for private/secure categories
Feature request: Topic-specific reply template
Feature request: Topic-specific reply template
Feature request: Topic-specific reply template
Feature request: Topic-specific reply template
Link to New Topic?
Open Composer with Prefilled information
[Solved] In plugin: opening the composer without changing the route
Have url for creating topic with specific title
Topic Templates
A community effort to improve Discourse's documentation
URL parameters for title and post content
Start a topic by pasting a link (like Reddit)
(Erlend Sogge Heggen) #2

Holy crabtarts, that’s amazing! :fish_cake:

Sorry to be that guy, but, any chance tags could be included in this? :sweat_smile:

A couple use cases:

  • A simple way to track the number of topics that are made via URL (can be done with unique text pre-fills as well, but this is cleaner)

  • If instead of a single topic like in wp-discourse, a page could be attached to a tag and would list all topics with that tag, that would pave the way for multi-topic pages fitting for plugins entries or documentation pages. (WordPress example, Vanilla example).


What are Topic Templates?
(Michael Downey) #3

This is exciting. How does one specify a subcategory?


(Arpit Jalan) #4

Currently, simply specifying subcategory name in category param, selects the correct subcategory: Discourse Meta

But, this made me think about the case of duplicate subcategory names. Currently I have not handled duplicate subcategory names issue. Will make sure I do handle this case by accepting the param subcategory, this way user can explicitly specify desired category/subcategory. Added on my list.


(Kane York) #5

Accepting numeric category IDs as well would work.


(Arpit Jalan) #6

Sent a PR to accept category_id as param instead of category name to better support subcategories.

https://github.com/discourse/discourse/pull/3420


(Руслан Корнев) #7

Hi, any plans for also edit post?


(Jeff Atwood) #8

I think it would be better if you supported

support/wordpress

Where the whole string can be slash delimited to indicate subcategory. The URL would be cleaner


(Arpit Jalan) #9

Okay, new-topic route now supports URL like:

Discourse Meta

Note that if both category_id and category is passed as param than priority is given to category_id.


https://github.com/discourse/discourse/pull/3434


#10

This is a great feature! I noticed that if you are not logged in and click on the link it prompts you to login, which is good. After you login, however, it brings you to homepage. Any chance that after logging in it would proceed with directing you to that link?


(Erlend Sogge Heggen) #11

Any update on the tags question? Seems a decent amount of people were interested.


(Jeff Atwood) #13

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.


(Arpit Jalan) #14

Should be fixed via:

https://github.com/discourse/discourse/commit/d1632c1dbd256411bbb348f638bb7f5f61f05eae


New Topic URL - Lost if not logged in
(Arpit Jalan) #15

Okay, composing a new (pre-filled) topic via URL now supports (multiple) tags! :sunny:

Updated the OP with example for adding tags.