5 Replies Latest reply on Jun 4, 2015 8:59 AM by l9rezn

    Displaying a user attributes in a HTML widget

      Is there a quick easy way of displaying a user attribute in an html widget?


      I want to display their first name so that we can personalize the page?


      I also want to use the same attribute to personalize a url


      Walter Gildersleeve

      Ian Pearce


      Gary Wood

        • Re: Displaying a user attributes in a HTML widget

          Hello Miles Clement


          for a quick way to do this, you can use jQuery to interrogate the element in the header that always shows the Username ... the actual name is within an anchor tag, and looks something like this;-


          <a href="/people/admin" data-username="admin" data-avatarid="-1" data-userid="1" data-online="false" data-presence="null" data-externalid="" class="jive-username-link   ">Fred Bloggs</a>


          you can then use jQuery to fiddle about with the name you get and insert it into your HTML widget within a named element.


          jQuery will be available, since it's used extensively within the UI, and you can add the logic to do the work directly to your widget as in-line script.



            • Re: Displaying a user attributes in a HTML widget



              Thanks for the suggestion

              Looking at the page source there is already a variable we can use: _jive_effective_user_id

              I have a jquery script that will then create the personalized url shown below.

              The code works as a self contained web page

              If i put it into a html widget it does not display anything

              I'm logged in as an admin which should allow me to use scripts and it does in some cases. However this is not one of those.


              Can you suggest why this may not work? or a better way of doing it?



              <!-- This would come from the main page but is included so that if you cut and paste the code into a stand-alone file it works -->

              <script type="text/javascript">

                      var _jive_effective_user_id = "7936";



              <!-- this is the text that would display -->

              The url is <URL></URL>


              <!-- this is a link to the jquery code source - is there a local copy we can reference? -->

              <script src="http://code.jquery.com/jquery-latest.js"></script>


              <!-- this code creates a varable with a constructed url based on the user id. It then replaces the tag <YRL> with teh constructuted URL -->


                var MyUrl = "<a href='https://www.securityforum.org/" + _jive_effective_user_id + "'>link</a>";



                • Re: Displaying a user attributes in a HTML widget

                  Hi Miles Clement


                  in order to use script tags in HTML widgets, you need to have admin privileges for that Space/Group.


                  Also note that getting alerts to display is liekly to cause some challenges for the page display (well, it did for me when I was testing !)


                  A couple of useful points though ...


                  i) we use '$j' to reference the jQuery namespace, and using that means you can make use of the libs that get pulled in automatically.

                  ii) I prefer to use span (or div) elements, simply because they are easy to attach an ID to and hence easy to find. Here's an example I pasted into my test instance which works for me.


                  Here is some text for you:

                  <span id='fred'></span>


                    var MyUrl = "<a href='https://www.securityforum.org/44545'>link</a>";





                  hope that helps