我正在尝试创建与下面相同的解决方案,但使用一个简单的 MySQL 查询(而不是下面使用的静态版本,其中在代码中实现了单词/标签)。MySQL 表的名称是“tags”,它有 2 列“id”和“tag”。
不幸的是,我是初学者,我无法解决这个问题。有人能帮我吗?
/* Zend_Tag_Item version*/
$list = new Zend_Tag_ItemList();
$list[] = new Zend_Tag_Item(array('title' => 'Code', 'weight' => 50));
$list[] = new Zend_Tag_Item(array('title' => 'Zend Framework', 'weight' => 1));
$list[] = new Zend_Tag_Item(array('title' => 'PHP', 'weight' => 5));
$list->spreadWeightValues(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10));
foreach ($list as $item) {
$this->view->tagtitle = $item->getTitle();
$this->view->tagweight = $item->getParam('weightValue');
}
/* Zend_Tag_Cloud version*/
$cloud = new Zend_Tag_Cloud(array(
'tags' => array(
array('title' => 'Code', 'weight' => 50,
'params' => array('url' => '/tag/code')),
array('title' => 'Zend Framework', 'weight' => 1,
'params' => array('url' => '/tag/zend-framework')),
array('title' => 'PHP', 'weight' => 5,
'params' => array('url' => '/tag/php')),
)
));
$formdata->pagecontent->tagging = $cloud;