Tag Cloud for Plone 3

I was building new site using Plone 3.1.7. I had to install tag cloud for the site and I couldn’t find any add-on product that I can use for this version. So decided to use TagCloudxplorer product by applying small patches for making it compatible to Plone 3.

Product:

Dependencies

After copying this two products in Plone product directory which is generally (path_to_plone_instance /data/products/). Open install.py which is resting at Data\Products\TagCloudExplorer\Extensions\

Search for below code under install definition.

addPortlet(self, outStream)

and comment it out because Plone 3 got different portlet layout which is no longer use classic portlet used in Plone 2.After commenting out code definition of install method look like below.

def install(self) :
    outStream = StringIO()
    skinsTool = getToolByName(self, 'portal_skins')
    addDirectoryViews(skinsTool, 'skins', config.GLOBALS)
    installSubSkin(self, config.SKIN_NAME, outStream)
    #installSubSkin(self, config.SKIN_OVERLOAD_NAME, outStream)
    addTool(self, outStream)
    #addPortlet(self, outStream)
    #addActionProvider(self)
    setupCSS(self, outStream)
    installConfiglet(self, outStream)
    addCacheManager(self, outStream)
    return outStream.getvalue()

This portlet need to add in Plone 3 portlet column. Navigate to to section where you would like add this portlet and click then manage portlets. you can manage portlet by placing “@@manage-portlets” at end of the URL in the browser. Add classic portlet on right or left column.

Give template name portlet_tag_cloud_explorer and portlet as a macro name to custom classic portlet.

TagCloudExplorer provide a configuration page available from the control panel. Mainly I use allowed stated Published with exponential method with min 1, max 4 and size 10 as tags scale mapping.

Add remove multiple HTML element using Javascript


Here is quick script for adding HTML element dynamically.Limit can be set for these element This script can add number for various HTML element.

DEMO

Filed 1

+

Filed 2

+

Script

 var count =1;
var limit = 5;
var var_name =new Array();
function addInput(divName){

     if (!var_name[divName.concat("_count")]){
      var_name[divName.concat("_count")] = 1}

     if (parseInt(var_name[divName.concat("_count")]) >= limit)  {
          alert("You have reached the limit of adding " + limit + " inputs");}
     else {
          var newdiv = document.createElement('div');
          newdiv.setAttribute("id", divName+(count+1));
          newdiv.innerHTML = "
-
";
          document.getElementById(divName).appendChild(newdiv);
          var_name[divName.concat("_count")]= parseInt(var_name[divName.concat("_count")]) +1;
          count++;
        }
}

function removeInput(divName,newdiv){
    var parentBox = document.getElementById(divName);
    var childBox = document.getElementById(newdiv);
    parentBox.removeChild(childBox);
    var_name[divName.concat("_count")]= parseInt(var_name[divName.concat("_count")])-1;
    count--;
}

HTML

+

Beware of TajPhone ! Nightmare to deal with them.

Never deal with these company. It was nightmare for me to get my money back.They are claiming to make cheaper call to India. Initially I chat with the customer services for while to get package information. When I pay them customer service guy told me that your account will be activated with in one hour.  While I wanted to make urgent call  I was getting inpatient with the services they offering. After while back I contacted again with customer services and same guy came up again telling me it will take time as technical setup need to be done. I might be wrong but it seems to me one man company. I have used various different international calling services and no one ask me to wait for minute they just charge the money and  straight away you can start using there service. Thanks god I used Paypal to send money and I was bit suspicious about the company that they might be fraud.

It was time for me to take action to get my hard earn money back. I raised issues with them in paypal and that same guy called me in next minute asking me to close the dispute and he will send me money back. I should say don’t deal with these company it was nightmare for me.

Javascript validator for group of radio button

After spending long time on Google for getting decent javascript for checking radio button for more then one group selected or not.  I came up with this script which check whether radio button is selected or not and give warning message for selecting radio button.

Javascript

 function check(e){
for(var i=0;i<e.length;i++){
if(e[i].type=='radio'){
  var r=e[e[i].name],
  q=true
  for(var j=0;j<r.length;j++){
   if(r[j].checked){
     q=false;}
  else{
    p=r[j].name}}
if(q){alert('Please select an option in '+p+' radio group'  );return false} } } }

HTML

 <form name="myform" onsubmit="return check(this.elements)">
   <input type="radio" name="group1" value="value1"/>
   <input type="radio" name="group1" value="value2"/>
   <input type="radio" name="group1" value="value3"/>

   <input type="radio" name="group2" value="value1"/>
   <input type="radio" name="group2" value="value2"/>
   <input type="radio" name="group2" value="value3"/>

   <input type="radio" name="group3" value="value1"/>
   <input type="radio" name="group3" value="value2"/>
   <input type="radio" name="group3" value="value3"/>

 <input type="submit" />
</form>

There is always chance for improvement so please comment !