Announcement

Collapse
No announcement yet.

Search JSON for use in Navbar for "My Recent Posts"

Collapse
This topic has been answered.
X
X
Collapse
First Prev Next Last
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Search JSON for use in Navbar for "My Recent Posts"

    I want to add a Navbar link for "My Recent Posts" like in the Mod Add "My Started Topics" Navigation Bar Menu Item. So I took a look at the link in the user dropdown menu at the top of the page. The JSON search string would be like

    Code:
    searchJSON=%7B%22authorid%22%3A%5B%222%22%5D%2C%22view%22%3A%22topic%22%2C%22channel%22%3A%222%22%2C %22exclude_type%22%3A%5B%22vBForum_PrivateMessage% 22%5D%2C%22sort%22%3A%7B%22lastcontent%22%3A%22des c%22%7D%7D
    The next thing I did was decoding URI with this result

    Code:
    {"authorid":["2"],"view":"topic","channel":"2","exclude_type":["vBForum_PrivateMessage"],"sort":{"lastcontent":"desc"}}
    In "authorid":["2"] "2" is my actual userid. I understood that this has to be dynamically changed to the calling userid on click on the Navbar link.

    So my idea was to use the onclick from the mod Add "My Started Topics" Navigation Bar

    Code:
    onclick="this.href=this.href.replace('*username*', encodeURIComponent(pageData.username))" oncontextmenu="this.href=this.href.replace('*username*', encodeURIComponent(pageData.username))"
    and to change it for the use of the actual userid. This the point where Í got stuck. How can I determine and reference the actual userid? Can I derive it from the username and if yes, how?

    Ideas anybody?

    Thanks in avdance.​
  • Answer selected by flohse at 03-07-2026, 01:45 PM.

    And since userid is just a number, you don't have to encode it.

    Code:
    this.href=this.href.replace('*username*', pageData.userid)
    You may want to use *userid* as placeholder instead of *username* to avoid confusion.

    Code:
    this.href=this.href.replace('*userid*', pageData.userid)

    Comment


    • flohse
      commented
      Editing a comment
      Thanks, enjoy your coffee.

    #2
    Use pageData.userid instead of pageData.username.
    Buy me a coffeePayPal QR Code
    My Amazon Affiliate Link
    Fast vBulletin VPS Host:
    This site is hosted by IONOS

    Comment


      #3
      And since userid is just a number, you don't have to encode it.

      Code:
      this.href=this.href.replace('*username*', pageData.userid)
      You may want to use *userid* as placeholder instead of *username* to avoid confusion.

      Code:
      this.href=this.href.replace('*userid*', pageData.userid)
      Buy me a coffeePayPal QR Code
      My Amazon Affiliate Link
      Fast vBulletin VPS Host:
      This site is hosted by IONOS

      Comment


      • flohse
        commented
        Editing a comment
        Thanks, enjoy your coffee.

    Latest Posts

    Collapse

    Working...
    X
    Searching...Please wait.
    An unexpected error was returned: 'Your submission could not be processed because you have logged in since the previous page was loaded.

    Please push the back button and reload the previous window.'
    An unexpected error was returned: 'Your submission could not be processed because the token has expired.

    Please push the back button and reload the previous window.'
    An internal error has occurred and the module cannot be displayed.
    There are no results that meet this criteria.
    Search Result for "|||"