+

Search Tips   |   Advanced Search

Tagging and rating for static pages


To add tagging or rating to static pages, we add the tagging or rating widget to the HTML code.

For details about how to do this refer to the topic about the default tagging and rating user interface.

the following examples show how we add tagging and rating to static pages.


Add the widgets using Javascript code

The following example shows how you integrate tag and rating widgets to your programming code:

<div>
    <script type="text/javascript">
 
   // Create inline widgets programmatically       function showInlineTagWidget(uri, title, domNode)
      {
          var widget = new com.ibm.widgets.InlineTag({resourceID: uri, resourceTitle: title});
          dojo.place(widget.domNode, domNode, "last");
          return true;
      }

      function showInlineRatingWidget(uri, title, domNode)
      {
          var widget = new com.ibm.widgets.InlineRating({resourceID: uri, resourceTitle: title});
          dojo.place(widget.domNode, domNode, "last");
          return true;
      }

      showInlineTagWidget("mycustomcontent:001", "MyCustomContent 001", dojo.byId("inlineTagWidget"));
      showInlineRatingWidget("mycustomcontent:002", "MyCustomContent 001", dojo.byId("inlineTagWidget"));
  
   // Create dialog widget programmatically       function showTagWidget(uri, title)
      {
          var widget = new com.ibm.widgets.AddTag({resourceID: uri, resourceTitle: title});
          return true;
      } 

   // Create dialog widget programmatically       function showRatingWidget(uri, title)
      {
          var widget = new com.ibm.widgets.AddRating({resourceID: uri, resourceTitle: title});
          return true;
      }   

</script>


<!-- Programmatic approach for including the dialog widgets -->
     Some content to be tagged and rated goes here...
     <a href="http://setgetweb.com/p/portal80/#" onClick="javascript:showTagWidget('mycustomcontent:001', 'MyCustomContent 002');">Tag</a>
     <a href="http://setgetweb.com/p/portal80/#" onClick="javascript:showRatingWidget('mycustomcontent:002', 'MyCustomContent 002');">Rate</a>
     <br/><br/>
 
<!-- Programmatic approach for including the inline widgets -->
     Some content to be tagged and rated goes here...
     <div id="inlineTagWidget"/>
     <div id="inlineRatingWidget"/>

</div>


Add the widgets using HTML markup

The following example shows how you integrate an inline tag and rating widgets by declaration:

<!-- Declarative approach for including the inline widgets -->
     Some content to be tagged and rated goes here...

     <script type="text/javascript">
     dojo.addOnLoad(function()
          {
               dojo.forEach(["inlineWidgets"], dojo.parser.parse, dojo.parser);
          });
     </script>

     <div id="inlineWidgets">
          <div dojoType="com.ibm.widgets.InlineTag" resourceId="mycustomuri:003" 
               resourceTitle="MyCustomContent 003" displayTwisty="expanded"></div> 
          <div dojoType="com.ibm.widgets.InlineRating" resourceId="mycustomuri:003" 
               resourceTitle="MyCustomContent 003" displayTwisty="expanded"></div> 
     </div>


Parent: Tagging and rating
Related:
Search for tagged content
Federating tags
Related reference:
How tagging and rating works in the portal
The tagging and rating user interface
Allow our own custom content to be tagged and rated
Configuration reference
Security for tagging and rating
Use xmlaccess.sh to administer tags and ratings
Administration of tag federation
Tips for tagging and rating
The tagging and rating user interface