Find by Slug or Create
I'm integrating NodeBB with another system and need a URL which will:
- Find a topic using only a slug, without the topic id.
- If the topic is found, show the topic page.
- If no topic is found, show the user the New Topic page and associate it with a category.
For example, I hit the URL:
The browser then redirects to either
or to a New Topic page for the given category:
Is there any built-in way to do this? Or are there any plug-ins which will do this?
Hm, that's fairly difficult, as the slugs are not used as a unique identifier. You can make topics with the same title, they'll just have different topics IDs.
If there were multiple topics with the same slug I would show the user a list of those topics with a summary text of the body content and allow them to click on the one they want to read.
Anyone know of some sample code to find a list of topics based on the slug?