code: function() {
          var attributions = [];
          if (this.map && this.map.layers) {
              for(var i=0, len=this.map.layers.length; i<len; i++) {
                  var layer = this.map.layers[i];
                  if (layer.attribution && layer.getVisibility()) {
                      // add attribution only if attribution text is unique
                      if (OpenLayers.Util.indexOf(
                                      attributions, layer.attribution) === -1) {
                          attributions.push( layer.attribution );
                      }
                  }
              } 
              this.div.innerHTML = OpenLayers.String.format(this.template, {
                  layers: attributions.join(this.separator)
              });
          }
      }
docs: Method: updateAttribution
  Update attribution string.