src/View/Helper/TagCloudHelper.php
public function display(array $tags, array $options = [], array $attrs = []) {
		if (empty($tags)) {
			return '';
		}
		$options += $this->_config;

		$tags = $this->calculateWeights($tags);

		$weights = Hash::extract($tags, $options['extract']);
		$maxWeight = max($weights);
		$minWeight = min($weights);

		// find the range of values
		$spread = $maxWeight - $minWeight;
		if ($spread == 0) {
			$spread = 1;
		}

		if ($options['shuffle'] == true) {
			shuffle($tags);
		}

		$cloud = [];
		foreach ($tags as $tag) {
			$tagWeight = $tag['weight'];

			$size = $options['minSize'] + (
				($tagWeight - $minWeight) * (
					($options['maxSize'] - $options['minSize']) / $spread
				)
			);
			$size = $tag['size'] = ceil($size);

			$content = $this->Html->link(
				$tag[$options['tagModel']]['label'],
				$this->_tagUrl($tag, $options),
				['id' => 'tag-' . $tag[$options['tagModel']]['id']]
			);
			$data = compact('size', 'content');
			$cloud[] = $this->templater()->format('item', $data);
		}

		$content = implode(PHP_EOL, $cloud);
		$attrs = $this->templater()->formatAttributes($attrs);
		$data = compact('attrs', 'content');

		return $this->templater()->format('wrapper', $data);
	}
public function display(array $tags, array $options = [], array $attrs = []) {
		if (empty($tags)) {
			return '';
		}
		$options += $this->_config;

		$tags = $this->calculateWeights($tags);

		$weights = Hash::extract($tags, $options['extract']);
		$maxWeight = max($weights);
		$minWeight = min($weights);

		// find the range of values
		$spread = $maxWeight - $minWeight;
		if ($spread == 0) {
			$spread = 1;
		}

		if ($options['shuffle'] == true) {
			shuffle($tags);
		}

		$cloud = [];
		foreach ($tags as $tag) {
			$tagWeight = $tag['weight'];

			$size = $options['minSize'] + (
				($tagWeight - $minWeight) * (
					($options['maxSize'] - $options['minSize']) / $spread
				)
			);
			$size = $tag['size'] = ceil($size);

			$content = $this->Html->link(
				$tag[$options['tagModel']]['label'],
				$this->_tagUrl($tag, $options),
				['id' => 'tag-' . $tag[$options['tagModel']]['id']]
			);
			$data = compact('size', 'content');
			$cloud[] = $this->templater()->format('item', $data);
		}

		$content = implode(PHP_EOL, $cloud);
		$attrs = $this->templater()->formatAttributes($attrs);
		$data = compact('attrs', 'content');

		return $this->templater()->format('wrapper', $data);
	}
public function display ( array $ tags , array $ options = [ ] , array $ attrs = [ ] ) { if ( empty ( $ tags ) ) { return '' ; } $ options += $ this -> _config ; $ tags = $ this -> calculateWeights ( $ tags ) ; $ weights = Hash :: extract ( $ tags , $ options [ 'extract' ] ) ; $ maxWeight = max ( $ weights ) ; $ minWeight = min ( $ weights ) ; // find the range of values $ spread = $ maxWeight - $ minWeight ; if ( $ spread == 0 ) { $ spread = 1 ; } if ( $ options [ 'shuffle' ] == true ) { shuffle ( $ tags ) ; } $ cloud = [ ] ; foreach ( $ tags as $ tag ) { $ tagWeight = $ tag [ 'weight' ] ; $ size = $ options [ 'minSize' ] + ( ( $ tagWeight - $ minWeight ) * ( ( $ options [ 'maxSize' ] - $ options [ 'minSize' ] ) / $ spread ) ) ; $ size = $ tag [ 'size' ] = ceil ( $ size ) ; $ content = $ this -> Html -> link ( $ tag [ $ options [ 'tagModel' ] ] [ 'label' ] , $ this -> _tagUrl ( $ tag , $ options ) , [ 'id' => 'tag-' . $ tag [ $ options [ 'tagModel' ] ] [ 'id' ] ] ) ; $ data = compact ( 'size' , 'content' ) ; $ cloud [ ] = $ this -> templater ( ) -> format ( 'item' , $ data ) ; } $ content = implode ( PHP_EOL , $ cloud ) ; $ attrs = $ this -> templater ( ) -> formatAttributes ( $ attrs ) ; $ data = compact ( 'attrs' , 'content' ) ; return $ this -> templater ( ) -> format ( 'wrapper' , $ data ) ; }
Method to output a tag-cloud formatted based on the weight of the tags

Valid option keys are:
- shuffle: true to shuffle the tag list, false to display them in the same order than passed [default: true]
- extract: Hash::extract() compatible format string. Path to extract weight values from the $tags array
[default: {n}.weight]
- templates: Set your wrapper and item (usually ul/li elements). {{size}} will be replaced with tag size calculated
from the weight
- maxSize: size of the heaviest tag [default: 160]
- minSize: size of the lightest tag [default: 80]
- url: an array containing the default url
- named: the named parameter used to send the tag [default: by].

@param array $tags Tag array to display.
@param array $options Display options.
@param array $attrs For ul element
@return string
Method to output a tag - cloud formatted based on the weight of the tags