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:

    /topic/this-is-a-topic?category=the-category
    

    The browser then redirects to either

    /topic/99/this-is-a-topic
    

    or to a New Topic page for the given category:

    /categories/88/the-category/new-topic
    

    Is there any built-in way to do this? Or are there any plug-ins which will do this?


  • Admin

    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?


Log in to reply
 


Star

Looks like your connection to NodeBB was lost, please wait while we try to reconnect.