Widget logic

Unsolved Technical Support
  • No, this would have to go into a new or existing plugin. It is essentially a new widget with custom logic that would live on the server side. Like the widgets we have in nodebb-widget-essentials.

  • @baris Ok, thanks.

  • @baris Seems I can do most of this in a standard HTML widget - I'm only missing the OP ID and the logged in user ID for analysis in relation to triggering the message or not - an example below

    <!-- IF isQuestion -->
    <!-- IF !isSolved -->
    <div class="bmacmain">
    <div class="card"><h5 class="card-header">Did this topic help you?</h5><div class="card-body">
    <div class="bmacmessage">Please don't forget to click on "Mark this post as the correct answer" whenever the information provided helps you. Original posters help the community find answers faster by identifying the correct answer. 
    </div>
    </div>
    </div></div>
    <br>
    <style>
    #bmac {
    display: none;
    }
    </style>
    <!-- ENDIF !isQuestion -->
    <!-- ENDIF !isSolved -->
    
  • You can try {{{ if (uid === loggedInUser.uid)}}} some text{{{ end }}} as long as your theme is providing the loggedInUser object. Like harmony and persona.

  • @baris Thanks. This works ๐Ÿ™‚

    <!-- IF isQuestion -->
    <!-- IF !isSolved -->
    < script > 
    {{ if (uid === loggedInUser.uid) }} 
    </script> 
    <div class = "bmacmain" > 
    <div class = "card" > 
    <h5 class = "card-header" > Did this topic help you ? < /h5>
    <div class="card-body"> 
    <div class = "bmacmessage" > Please don 't forget to click on "Mark this post as the correct answer" whenever the information provided helps you. Original posters help the community find answers faster by identifying the correct answer.  < /div> 
    </div> 
    </div>
    </div> 
    <br> 
    <script> 
    {{ end }} 
    </script>
    <!-- ENDIF !isQuestion -->
    <!-- ENDIF !isSolved -->
    
  • Hmm - not working entirely - it is triggering no matter who the OP is

    <script>
    {{{ if (uid === loggedInUser.uid) }}}
    </script>
    <!-- IF isQuestion -->
    <!-- IF !isSolved -->
    <div class="bmacmain">
    <div class="card"><h5 class="card-header">Did you get the answer you needed?</h5><div class="card-body">
    <div class="bmacmessage">Hey <span class="topicUsername" ><span class="username"></span></span>. It looks as though there have been one or more replies to your original post. <br>If a provided answer resolved an issue for you, Could you please take a moment, and select "Mark this post as the correct answer" in the corresponding response?  <br><br>By doing this, it means that original posters help the rest of the community find answers to previously asked questions by identifying the correct answer. 
    </div>
    </div>
    </div></div>
    <br>
    <!-- ENDIF !isQuestion -->
    <!-- ENDIF !isSolved -->
    <script>
    {{{ end }}}
    </script>
    

    Still lookin at this, but any thoughts ?

  • You don't have to put that in <script> tags. It is valid benchpress so you can use something like this.

    {{{ if (uid == loggedInUser.uid) }}}
    {{{ if isQuestion }}}
    {{{ if !isSolved }}}
    <div class="bmacmain">
    <div class="card"><h5 class="card-header">Did you get the answer you needed?</h5><div class="card-body">
    <div class="bmacmessage">Hey <span class="topicUsername" ><span class="username"></span></span>. It looks as though there have been one or more replies to your original post. <br>If a provided answer resolved an issue for you, Could you please take a moment, and select "Mark this post as the correct answer" in the corresponding response?  <br><br>By doing this, it means that original posters help the rest of the community find answers to previously asked questions by identifying the correct answer. 
    </div>
    </div>
    </div></div>
    <br>
    {{{ end }}}
    {{{ end }}}
    {{{ end }}}
    
    
  • @baris of course. Forgot. Let me try that

    Edit - works perfectly. Thanks

  • I would recommend combining those ifs:

    {{{ if (((uid == loggedInUser.uid) && isQuestion) && !isSolved) }}}

  • @PitaJ yes, that would be more efficient I expect. Thanks


Suggested Topics