src/Model/Table/TaggedTable.php
public function findCloud(Query $query) {
		$groupBy = ['Tagged.tag_id', 'Tags.id', 'Tags.slug', 'Tags.label'];
		$fields = $groupBy;
		$fields['counter'] = $query->func()->count('*');

		// FIXME or remove
		// Support old code without the counter cache
		// This is related to https://github.com/CakeDC/tags/issues/10 to work around a limitation of postgres
		/*
		$field = $this->getDataSource()->fields($this->Tag);
		$field = array_merge($field, $this->getDataSource()->fields($this, null, 'Tagged.tag_id'));
		$fields = 'DISTINCT ' . implode(',', $field);
		$groupBy = null;
		*/

		$options = [
			'minSize' => 10,
			'maxSize' => 20,
			//'page' => '',
			//'limit' => '',
			//'order' => '',
			//'joins' => array(),
			//'offset' => '',
			'contain' => 'Tags',
			//'conditions' => array(),
			'fields' => $fields,
			'group' => $groupBy
		];

		$query->formatResults(function (CollectionInterface $results) {
			$results = static::calculateWeights($results->toArray());

			return $results;
		});

		return $query->find('all', $options);
	}
public function findCloud(Query $query) {
		$groupBy = ['Tagged.tag_id', 'Tags.id', 'Tags.slug', 'Tags.label'];
		$fields = $groupBy;
		$fields['counter'] = $query->func()->count('*');

		// FIXME or remove
		// Support old code without the counter cache
		// This is related to https://github.com/CakeDC/tags/issues/10 to work around a limitation of postgres
		/*
		$field = $this->getDataSource()->fields($this->Tag);
		$field = array_merge($field, $this->getDataSource()->fields($this, null, 'Tagged.tag_id'));
		$fields = 'DISTINCT ' . implode(',', $field);
		$groupBy = null;
		*/

		$options = [
			'minSize' => 10,
			'maxSize' => 20,
			//'page' => '',
			//'limit' => '',
			//'order' => '',
			//'joins' => array(),
			//'offset' => '',
			'contain' => 'Tags',
			//'conditions' => array(),
			'fields' => $fields,
			'group' => $groupBy
		];

		$query->formatResults(function (CollectionInterface $results) {
			$results = static::calculateWeights($results->toArray());

			return $results;
		});

		return $query->find('all', $options);
	}
public function findCloud ( Query $ query ) { $ groupBy = [ 'Tagged.tag_id' , 'Tags.id' , 'Tags.slug' , 'Tags.label' ] ; $ fields = $ groupBy ; $ fields [ 'counter' ] = $ query -> func ( ) -> count ( '*' ) ; // FIXME or remove // Support old code without the counter cache // This is related to https://github.com/CakeDC/tags/issues/10 to work around a limitation of postgres /*
		$field = $this->getDataSource()->fields($this->Tag);
		$field = array_merge($field, $this->getDataSource()->fields($this, null, 'Tagged.tag_id'));
		$fields = 'DISTINCT ' . implode(',', $field);
		$groupBy = null;
		*/ $ options = [ 'minSize' => 10 , 'maxSize' => 20 , //'page' => '', //'limit' => '', //'order' => '', //'joins' => array(), //'offset' => '', 'contain' => 'Tags' , //'conditions' => array(), 'fields' => $ fields , 'group' => $ groupBy ] ; $ query -> formatResults ( function ( CollectionInterface $ results ) { $ results = static :: calculateWeights ( $ results -> toArray ( ) ) ; return $ results ; } ) ; return $ query -> find ( 'all' , $ options ) ; }
Returns a tag cloud

The result contains a "weight" field which has a normalized size of the tag
counter set. The min and max size can be set by passing 'minSize" and
'maxSize' to the query. This value can be used in the view to control the
size of the tag font.

@param \Cake\ORM\Query $query Query array.
@return \Cake\ORM\Query
Returns a tag cloud