怎么把tag文章列表的最旧的一条信息的description作为页面描述
我的是免费无授权版本,3.2.
以下是tag模板获取文章列表的代码:
{list action=sql sql='$tagsql' module=$dirname page=1 urlrule=$urlrule pagesize=15 order=updatetime}
{$t.title}{dr_strcut($t.description,85)}
{/list}
问题:怎么把tag所获取的文章列表中最旧的一条信息的description作为本页面的描述
<?php $meta = $ci->db->select('description,title')->where('status',9)->where($ci->db->like('title', $tag, 'both')->or_like('title', $tag, 'both'))->limit(1)->order_by('updatetime ASC')->get(SITE_ID.'_'.$dirname)->row_array(); $meta_description = $meta['description']; ?>以上代码 放到 模板的 最最最上面,也就是第一行,试试看
<?php if($tag && $dirname){ $meta = $ci->db->select('description,title')->where('status',9)->where($ci->db->like('title', $tag, 'both')->or_like('title', $tag, 'both'))->limit(1)->order_by('updatetime ASC')->get(SITE_ID.'_'.$dirname)->row_array(); $meta_description = $meta['description']; } ?>更新一下,加个判断<?php if($tag && $dirname){ $meta = $ci->db->select('description,title')->where('status',9)->where($ci->db->like('title', $tag, 'both')->or_like('keywords', $tag, 'both'))->limit(1)->order_by('updatetime ASC')->get(SITE_ID.'_'.$dirname)->row_array(); $meta_description = $meta['description']; } ?>再更新一下,修改一下 用这个