我从以下链接使用yii标签云扩展 http://www.yiiframework.com/extension/yiitagcloud/
$this->widget('application.extensions.YiiTagCloud.YiiTagCloud',
array(
'beginColor' => '00089A',
'endColor' => 'A3AEFF',
'minFontSize' => 8,
'maxFontSize' => 20,
'arrTags' =>
array (
'MVC' => array('weight'=> 2),
'PHP' => array('weight'=> 9, 'url' => 'http://php.net'),
'MySQL' => array('weight'=> 8, 'url' => 'http://mysql.com'),
'jQuery' => array('weight'=> 6, 'url' => 'http://jquery.com'),
'SQL' => array('weight'=> 9),
'C#' => array('weight'=> 2),
),
)
);
它适用于手动或静态值,但我想在这里使用数组。数组结构就像这样
Array (
[toy] => 2
[not-possible ] => 1
[peace] => 1
[nedds] => 1
[fullfilment] => 1
[pakistan] => 1
[no-terrorism] => 1
[message-for-muslims] => 1
[a] => 1
[just ] => 1
[for-showoff] => 1
[a-dream] => 1
[peace-hen] => 1
[reality] => 1
)
其中key是标记,value是其频率。现在请问我有什么想法使用这个小部件吗?
答案 0 :(得分:0)
将频率换行array('weight' => frequency)
以获得类似于手动/静态的数组,并将此数组传递到小部件中。小部件将适当地处理加权。
答案 1 :(得分:0)
将标记和权重存储在以下结构中的数组中
Array (
[toy] => Array ( [weight] => 2 )
[not-possible ] => Array ( [weight] => 1 )
[peace] => Array ( [weight] => 1 )
[nedds] => Array ( [weight] => 1 )
[fullfilment] => Array ( [weight] => 1 )
[pakistan] => Array ( [weight] => 1 )
[no-terrorism] => Array ( [weight] => 1 )
[message-for-muslims] => Array ( [weight] => 1 )
[a] => Array ([weight] => 1 )
[just ] => Array ( [weight] => 1 )
[for-showoff] => Array ( [weight] => 1 )
[a-dream] => Array ( [weight] => 1 )
[peace-hen] => Array ( [weight] => 1 )
[reality] => Array ( [weight] => 1 )
)
并在行
的小部件中使用此数组 'arrtags'=>$tagsarray,
感谢@Topher的想法。