本文整理汇总了PHP中Tags::count方法的典型用法代码示例。如果您正苦于以下问题:PHP Tags::count方法的具体用法?PHP Tags::count怎么用?PHP Tags::count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tags
的用法示例。
在下文中一共展示了Tags::count方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fetchCidiansCloud
public function fetchCidiansCloud($cidianCloudNum)
{
$totalTags = Tags::count(array('is_cidian' => 1));
$randStart = mt_rand(0, $totalTags - $cidianCloudNum);
$tags = Tags::find(array('is_cidian' => 1, 'limit' => array('number' => $cidianCloudNum, 'offset' => $randStart)))->toArray();
$cidianBgs = array(1, 3);
foreach ($tags as $key => $tag) {
$randBg = mt_rand($cidianBgs[0], $cidianBgs[1]);
$tags[$key]['randBg'] = $randBg;
}
return $tags;
}
示例2: fetchWidgetData
public function fetchWidgetData($view, $block = '')
{
$widgetData = array();
$blockCfgKey = $block ? $view . '_' . $block : $view;
$blockCfg = $this->_siteConfig['blockCfg'][$blockCfgKey];
$blockNum = $this->_siteConfig['widgetCfg']['blockNum'];
switch ($view) {
case 'slider':
//理财故事
//理财故事
case 'btslider':
$widgetData[$block] = array('blockName' => $block, 'items' => $this->_siteConfig['slider'][$block]);
break;
case 'dailyword':
$dailyword['title'] = '天天词汇';
$dailyword['word'] = Tags::findFirst(array("conditions" => "is_cidian = ?1", "bind" => array(1 => 1)))->toArray();
$widgetData = $dailyword;
break;
case 'content':
switch ($block) {
case 'node':
$content = TreeData::findFirst($this->_params['nid'])->toArray();
$content['content'] = htmlspecialchars_decode($content['content']);
$widgetData[$block]['content'] = $content;
break;
case 'tag':
$content = Tags::findFirst($this->_params['tid'])->toArray();
$content['content'] = htmlspecialchars_decode($content['description']);
$content['title'] = $content['name'];
$widgetData[$block]['content'] = $content;
break;
case 'static':
$static_content = TreeStruct::findFirst(array("conditions" => "pid = ?1", "bind" => array(1 => $this->_params['nid']), 'order' => 'lft asc'));
$content = array();
if ($static_content) {
$content['title'] = $static_content->TreeData->title;
$content['content'] = htmlspecialchars_decode($static_content->TreeData->content);
}
$widgetData[$block]['blockName'] = $block;
$widgetData[$block]['content'] = $content;
break;
default:
break;
}
break;
case 'cidian':
$cidianCloudNum = $this->_siteConfig['widgetCfg']['cidianCloudNum'];
$tags = Tags::fetchCidiansCloud($cidianCloudNum);
$widgetData = $tags;
break;
case 'hangqing':
case 'lilv':
case 'tool':
break;
case 'taglist':
$taglist = array();
$itemPer = $this->_siteConfig['widgetCfg']['listItemPer'];
$start = ($this->_params['p'] - 1) * $itemPer;
if ($this->_params['tagPrefix']) {
$conditions = 'pinyinPrefix="' . $this->_params['tagPrefix'] . '" and is_cidian=1';
} else {
$conditions = 'is_cidian=1';
}
$taglist['items'] = Tags::find(array('conditions' => $conditions, 'order' => 'id desc', 'limit' => array('number' => $itemPer, 'offset' => $start)))->toArray();
$totalTags = Tags::count($conditions);
$params = array('total_rows' => $totalTags, 'now_page' => $this->_params['p'], 'list_rows' => $itemPer);
$pagerLib = new Pager($params);
$pager = $pagerLib->show(3);
$taglist['pager'] = $pager;
// echo '<pre>';print_r($taglist);echo '</pre>';
$widgetData = $taglist;
break;
case 'taglist_header':
$optRanges = array(97, 122);
$options = array();
$options[] = '0-9';
for ($i = $optRanges[0]; $i <= $optRanges[1]; $i++) {
$options[] = chr($i);
}
$widgetData = $options;
break;
case 'list':
switch ($block) {
case 'node':
$nodeLists = array();
$itemPer = $this->_siteConfig['widgetCfg']['listItemPer'];
$start = ($this->_params['p'] - 1) * $itemPer;
$temNodes = TreeStruct::find(array('conditions' => 'lft>?1 and rgt<?2 and type=:type:', 'bind' => array(1 => $this->_params['node']->lft, 2 => $this->_params['node']->rgt, 'type' => 'article'), 'limit' => array('number' => $itemPer, 'offset' => $start), 'order' => 'id desc'));
$nodes = array();
foreach ($temNodes as $key => $temNode) {
$treeData = $temNode->TreeData->toArray();
$nodes[$key] = $temNode->toArray();
$nodes[$key]['TreeData'] = $treeData;
}
$nodes = TreeStruct::addNodesAttr($nodes, array('menu' => true, 'menuLevel' => 1));
$totalNodes = TreeStruct::count(array('conditions' => 'lft>?1 and rgt<?2 and type=:type:', 'bind' => array(1 => $this->_params['node']->lft, 2 => $this->_params['node']->rgt, 'type' => 'article')));
$params = array('total_rows' => $totalNodes, 'now_page' => $this->_params['p'], 'list_rows' => $itemPer);
$pagerLib = new Pager($params);
$pager = $pagerLib->show(3);
$nodeLists['title'] = $this->_params['node']->TreeData->title;
//.........这里部分代码省略.........