Find by Slug or Create

General Discussion
  • 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?

  • 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?


Suggested Topics


  • 3 Votes
    3 Posts
    371 Views
  • 0 Votes
    1 Posts
    454 Views
  • 0 Votes
    3 Posts
    574 Views
  • How create a table

    General Discussion
    0 Votes
    6 Posts
    2514 Views
  • 0 Votes
    11 Posts
    3094 Views