eyoucms tags 标签调用使用方法

文章详细介绍了易优CMS中TAG标签的调用方法,包括基础用法和多个示例,涉及不同参数如排序方式、获取类型和循环控制等,适用于网站内容管理与展示。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

【基础用法】

标签:tags

描述:TAG调用

用法:

{eyou:tags sort='now' getall='0' loop='100'}

<a href='{$field.link}'>{$field.tag}</a>(文档数:{$field.total})

{/eyou:tags}

属性:

aid='' 文档ID,在内容页可以不设置该属性

typeid='' 栏目ID,调取某个栏目下的全部TAG

loop='100' 返回广告列表总数

getall='' 获取类型,0为当前内容页TAG标记,1为获取全部TAG标记
type='' 选择栏目方式

    type='son' 表示下级栏目
    type='self' 表示同级栏目
    type='top' 表示顶级栏目
    type='sonself' 表示当前下级栏目以及同级栏目
    type='first' 表示当前栏目ID的最顶级栏目下的第一级全部栏目

sort='' 标签排序方式

    sort='new' 按最新排序

    sort='rand' 随机排序

    sort='week' 按周统计排序

    sort='month' 按月统计排序

    sort='hot' 按点击数排序

    sort='total' 按文档数排序

name='' 变量

empty='' 没有数据时显示的文案

mod='' 每隔N行输出的内容

id='' 可以任意指定循环里的变量名替代field,假设id='field1',模板调用如:{$field.title} 变成 {$field1.title}

涉及表字段:

请查阅易优cms官方提供的数据字典,找到表名 ey_tagindex

【更多示例】

-------------------------------示例1--------------------------------

描述:输出当前文档页TAG标记

{eyou:tags getall='0'}

<a href='{$field.link}'>{$field.tag}</a>

{/eyou:tags}

-------------------------------示例2--------------------------------

描述:在任何页面输出任何文档的TAG标记

{eyou:tags getall='0' aid='3'}

<a href='{$field.link}'>{$field.tag}</a>

{/eyou:tags}

-------------------------------示例3--------------------------------

描述:输出指定栏目ID下的全部TAG标记

{eyou:tags getall='1' typeid='2' loop='50' sort='hot'}

<a href='{$field.link}'>{$field.tag}</a>

{/eyou:tags}

-------------------------------示例5--------------------------------

描述:内置变量输出数据索引与记录顺序,key 表示索引,默认从0开始;i 表示顺序,默认从1开始。

{eyou:tags getall='1' typeid='3' loop='5'}

{$key} - {$i}

{/eyou:tags}

效果:

0 - 1

1 - 2

2 - 3

3 - 4

4 - 5

-------------------------------示例6--------------------------------

描述:没有记录时输出文案提示,属性empty支持直接传入html语法(html里只支持双引号,禁止单引号)

{eyou:tags getall='1' typeid='3' empty='暂时没有数据'}

<a href='{$field.link}'>{$field.tag}</a>

{/eyou:tags}

-------------------------------示例7--------------------------------

描述:自定义变量名

{eyou:tags getall='1' typeid='3' id='field2'}

<a href='{$field2.link}'>{$field2.tag}</a>

{/eyou:tags}

转载:tags 标签调用-易优CMS 

/** * 搜索列表 */ public function lists() { $param = input('param.'); $users = session('?users') ? session('users') : []; $users_id = !empty($users['users_id']) ? intval($users['users_id']) : 0; $admin_id = !empty($users['admin_id']) ? intval($users['admin_id']) : 0; $nowTime = getTime(); /*记录搜索词*/ if (!isset($param['keywords'])) { die('标签调用错误:缺少属性 name="keywords",请查看标签教程修正 <a href="https://www.eyoucms.com/plus/view.php?aid=521" target="_blank">前往查看</a>'); } $word = $this->request->param('keywords'); if(empty($word)){ $this->error(foreign_lang('system15', $this->home_lang)); } $page = $this->request->param('page'); if(!empty($word) && 2 > $page) { $word_decode = htmlspecialchars_decode($word); $searchConf = tpCache('search'); if (!isset($searchConf['search_tabu_words'])) { $searchConf['search_tabu_words'] = ['<','>','"',';',',','@','&','#','\\','*']; } else { $searchConf['search_tabu_words'] = explode(PHP_EOL, $searchConf['search_tabu_words']); } /*前台禁止搜索开始*/ if (!empty($searchConf['search_tabu_words'])) { foreach ($searchConf['search_tabu_words'] as $key => $val) { if (strstr($word_decode, $val)) { $msg = sprintf(foreign_lang('system13', $this->home_lang), $val); $this->error($msg); } } } /*if (is_dir('./weapp/Wordfilter/')) { $wordfilterRow = Db::name('weapp')->where(['code'=>'Wordfilter', 'status'=>1])->find(); if(!empty($wordfilterRow['data'])){ $wordfilterRow['data'] = json_decode($wordfilterRow['data'], true); if ($wordfilterRow['data']['search'] == 3){ $wordfilter = Db::name('weapp_wordfilter')->where(['title'=>$word, 'status'=>1])->find(); if(!empty($wordfilter)){ $this->error('包含敏感关键词,禁止搜索!'); } } } }*/ /*前台禁止搜索结束*/ // 如果tag标签有,默认跳到tag列表页 /*$tagInfo = Db::name('tagindex') ->alias('a') ->field('a.id AS tagid') ->join('taglist b','a.id=b.tid','left') ->where(['a.tag'=>$word,'b.arcrank'=>['egt',0]]) ->find(); if (!empty($tagInfo)) { $city_switch_on = config('city_switch_on'); $domain = preg_replace('/^(http(s)?:)?(\/\/)?([^\/\:]*)(.*)$/i', '${1}${3}${4}', tpCache('web.web_basehost')); if (empty($city_switch_on)) { $tagurl = tagurl('home/Tags/lists', array('tagid'=>$tagInfo['tagid'])); } else { $tagurl = tagurl('home/Tags/lists', array('tagid'=>$tagInfo['tagid']), true, $domain); } $this->redirect($tagurl); exit; }*/ $word = addslashes($word); $method = input('param.method/d'); if (!empty($method)) { /*搜索频率限制 start*/ if (!isset($searchConf['search_second'])) { $searchConf['search_second'] = 60; } if (!isset($searchConf['search_maxnum'])) { $searchConf['search_maxnum'] = 5; } if (!isset($searchConf['search_locking'])) { $searchConf['search_locking'] = 120; } if (empty($admin_id) && 0 < $searchConf['search_second']) { $where = []; if (!empty($users_id)) { $where['users_id'] = $users_id; } else { $where['ip'] = clientIP(); } $where2 = [ 'update_time' => ['gt', $nowTime - $searchConf['search_second']], ]; $searchTotal = Db::name('search_word')->where($where)->where($where2)->count(); $lockingInfo = Db::name('search_locking')->where($where)->find(); if ($searchTotal >= intval($searchConf['search_maxnum'])) { if (empty($lockingInfo)) { $lockingInfo = [ 'users_id' => $users_id, 'ip' => clientIP(), 'locking_time' => $nowTime, 'add_time' => $nowTime, 'update_time' => $nowTime, ]; $insertId = Db::name('search_locking')->insertGetId($lockingInfo); $lockingInfo['id'] = $insertId; } else { if (($lockingInfo['locking_time'] + $searchConf['search_locking']) < $nowTime) { Db::name('search_locking')->where(['id'=>$lockingInfo['id']])->update([ 'locking_time' => $nowTime, 'update_time' => $nowTime, ]); $lockingInfo['locking_time'] = $nowTime; } } } if (!empty($lockingInfo)) { $locking_time = !empty($lockingInfo['locking_time']) ? $lockingInfo['locking_time'] : 0; $surplus_time = $locking_time + $searchConf['search_locking'] - $nowTime; if ($surplus_time > 0) { $minute = ceil($surplus_time/60); $msg = sprintf(foreign_lang('system14', $this->home_lang), $minute); $this->error($msg, null, [], $surplus_time); } } } /*搜索频率限制 end*/ /*记录搜索词*/ $row = $this->searchword_db->field('id')->where(['word'=>$word, 'lang'=>$this->home_lang])->find(); if(empty($row)) { $this->searchword_db->insert([ 'word' => $word, 'sort_order' => 100, 'users_id' => $users_id, 'ip' => clientIP(), 'lang' => $this->home_lang, 'add_time' => $nowTime, 'update_time' => $nowTime, ]); }else{ $this->searchword_db->where(['id'=>$row['id']])->update([ 'searchNum' => Db::raw('searchNum+1'), 'users_id' => $users_id, 'ip' => clientIP(), 'update_time' => $nowTime, ]); } } } /*--end*/ $result = $param; !isset($result['keywords']) && $result['keywords'] = ''; $eyou = array( 'field' => $result, ); $this->eyou = array_merge($this->eyou, $eyou); $this->assign('eyou', $this->eyou); /*模板文件*/ $viewfile = 'lists_search'; $channelid = input('param.channelid/d'); if (!empty($channelid)) { $viewfilepath = TEMPLATE_PATH.$this->theme_style_path.DS.$viewfile."_{$channelid}.".$this->view_suffix; if (file_exists($viewfilepath)) { $viewfile .= "_{$channelid}"; } } /*--end*/ if (config('city_switch_on') && !empty($this->home_site)) { // 多站点内置模板文件名 $viewfilepath = TEMPLATE_PATH.$this->theme_style_path.DS.$this->home_site; $viewfilepath2 = TEMPLATE_PATH.$this->theme_style_path.DS.'city'.DS.$this->home_site; if (!empty($this->eyou['global']['site_template'])) { if (file_exists($viewfilepath2)) { $viewfile = "city/{$this->home_site}/{$viewfile}"; } else if (file_exists($viewfilepath)) { $viewfile = "{$this->home_site}/{$viewfile}"; } } } else if (config('lang_switch_on') && !empty($this->home_lang)) { // 多语言内置模板文件名 $viewfilepath = TEMPLATE_PATH.$this->theme_style_path.DS.$viewfile."_{$this->home_lang}.".$this->view_suffix; if (file_exists($viewfilepath)) { $viewfile .= "_{$this->home_lang}"; } } return $this->fetch(":{$viewfile}"); } 检测sql注入利用链
最新发布
07-30
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

eyoucms

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值