Announcement

Collapse
No announcement yet.

#Hashtag BBCode

Collapse
X
Collapse
First Prev Next Last
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #Hashtag BBCode

    I saw this post over at vB.org and I was wondering what Search JSON I can use to get this working for vB5?

    #2
    Try:

    HTML Code:
    <a href="/search?q={param}">#{param}</a>
    But for tags with spaces, special characters (e.g. & or %) or accents, that might not work as the 'q' parameter value needs to be URL-encoded.

    Alternative solution is to use Javascript.

    HTML Code:
    <span data-p="{param}"></span>
    <script>
    (function() {
        var me = document.currentScript || (function() {
            var s= document.getElementsByTagName( 'script' );
            return s[s.length - 1];
        })();
        if (me) {
            var span = me.previousElementSibling;
            var param = span.getAttribute('data-p');
            span.innerHTML = '<a href="' + pageData.baseurl + '/search?q=' + encodeURIComponent(param) + '">#' + param + '</a>';
        }
    })();
    </script>
    Note that this code is untested.
    Helpful? Donate. Thanks!
    Buy me a coffeePayPal QR Code
    Fast VPS Host for vBulletin:
    A2 Hosting & IONOS

    Comment


      #3
      hi i am thinking to test on vb5
      is there any guide where to put this code

      thanks
      voyger.: In Almighty God I trust, everyone else has to provide evidence."

      Comment


        #4
        AdminCP > Custom BB Codes > Add New BB Code. The code above goes to Replacement field.
        Helpful? Donate. Thanks!
        Buy me a coffeePayPal QR Code
        Fast VPS Host for vBulletin:
        A2 Hosting & IONOS

        Comment


          #5
          The top one works perfectly!

          Comment


          • glennrocksvb
            glennrocksvb commented
            Editing a comment
            Did you test search keywords with spaces, special characters (?, & and %) and accents? Try in different browsers.

          #6
          Originally posted by glennrocksvb
          Did you test search keywords with spaces, special characters (?, & and %) and accents? Try in different browsers.
          • When entering multiple keywords, it only shows results for the first keyword
          • Special characters are working
          • Accents will give the message that your criteria is not restrictive enough
          For my forum only one word per hashtag is used and never special characters or accents, so to me all is well at the moment.

          Comment


            #7
            Tried to add the first code to the Custom BB Code .. but getting an error that html coding is incorrect (something on those lines).

            Comment


              #8
              So you're adding this HTML code in the Replacement field for the custom BBCode you are creating and you got an error when saving it?

              Code:
              <a href="/search?q={param}">#{param}</a>
              Can you post the exact error or a screenshot of the error?
              Helpful? Donate. Thanks!
              Buy me a coffeePayPal QR Code
              Fast VPS Host for vBulletin:
              A2 Hosting & IONOS

              Comment


                #9
                Don't understand why would it say that the html attributes should be enclosed within double quotes when they are within double quotes. I even removed the quotes thinking those might be ' and ' .. Tried by typing double quotes around the link.



                Comment


                  #10
                  Hmm figured out .. this works ..

                  Code:
                  <a href=www.site.com/search?q="{param}">#{param}</a>
                  Funny why your version worked for you but not for me ..

                  Edit .. Even this works ..

                  Code:
                  <a href="/search?q="{param}"">#{param}</a>

                  Comment


                    #11
                    Creating another reply because this is front-end discussion ..

                    At the front end, it does not work

                    When I add a hashtag to a post, it does show #item with a link on it but the link shows http://www.site.com/search?q=

                    No parameters. It should rather show http://www.site.com/search?q=item

                    Please advise. Thanks!

                    Comment


                      #12
                      It ultimately does not work as the double quotes are in the wrong places. Keep the original code and just click the Continue button when the error message appears and see what happens.
                      Helpful? Donate. Thanks!
                      Buy me a coffeePayPal QR Code
                      Fast VPS Host for vBulletin:
                      A2 Hosting & IONOS

                      Comment


                        #13
                        Oh wow man! I thought hitting Continue would just take me back to the main admin panel. It works now after hitting Continue. Sometimes I feel like dumb.

                        Thanks for the help Glenn, you really rock VB

                        Comment


                          #14
                          Glad to be helpful!
                          Helpful? Donate. Thanks!
                          Buy me a coffeePayPal QR Code
                          Fast VPS Host for vBulletin:
                          A2 Hosting & IONOS

                          Comment

                          Users Viewing This Page

                          Collapse

                          There is 1 user viewing this forum topic.

                          • Guest Guest

                          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 "|||"