Centos系统下载大全 | Redhat系统下载大全 | Windows2012系统下载大全 | Windows2008系统下载大全| CMS教程 | 网站地图 51运维网-专注Linux/Unix系统安全运维!
当前位置:51运维网 > CMS > dedecms > 正文

织梦dedecms5.7全站怎么按tag与关键字调用相关文章?

时间:2015-02-05 15:57 来源:网络整理 作者:51ou.com 阅读:

<?php
if(!defined('dedeinc')) exit('request error!');
/*--------------------------------------
按关键词关连文章的标签
eregtype属性
eregtype = keyword 只匹配关键字
eregtype = tag 只匹配tag
eregtype = all tag优先,不存在tag则匹配关键字
mytypeid='' 栏目id,多个栏目用,隔开
---------------------------------------*/
function lib_likearticle(&$ctag,&$refobj)
{
global $dsql;
//属性处理
$attlist="row|12,titlelen|28,infolen|150,col|1,tablewidth|100,mytypeid|0,byabs|0,imgwidth|120,imgheight|90";
fillattsdefault($ctag->cattribute->items,$attlist);
extract($ctag->cattribute->items, extr_skip);
$revalue = '';
if(empty($tablewidth)) $tablewidth = 100;
if(empty($col)) $col = 1;
$colwidth = ceil(100/$col);
$tablewidth = $tablewidth."%";
$colwidth = $colwidth."%";
$ids = array();
$tids = array();
$typeid = ( !empty($mytypeid) ? $mytypeid : 0 );
if(empty($typeid))
{
if(!empty($refobj->typelink->typeinfos['reid'])) {
$typeid = $refobj->typelink->typeinfos['reid'];
}
else {
if(!empty($refobj->fields['typeid'])) $typeid = $refobj->fields['typeid'];
}
}
if( !empty($typeid) && !ereg(',', $typeid) ) {
$typeid = getsonids($typeid);
}
if(!empty($refobj->fields['tags']) && $eregtype != 'keyword' )
{
$tags = explode(',', addslashes($refobj->fields['tags']));
$getsql = " tag like '".join("' or tag like '", $tags)."' ";
$dsql->execute('me', "select * from jbxue_tagindex where $getsql ");
while($arow = $dsql->getarray('me')) {
$tids[] = $arow['id'];
}
$tid = join(',', $tids);
if($tid!='')
{
$dsql->execute("me", "select aid from jbxue_taglist where tid in($tid) and arcrank > -1 group by aid order by aid desc limit 0, $row");
while($arow = $dsql->getarray("me"))
{
$ids[] = $arow['aid'];
$arcid = $refobj->fields['aid'];
}
}
}
if($eregtype == 'tag' && count($ids) == 0 )
{
return '';
}
else
{
if(count($ids) > 0)
{
if(!empty($typeid)) {
// $typeid = " and arc.typeid in($typeid) and arc.id<>$arcid "; 调用整站相关文章
$typeid = "and arc.id<>$arcid";
}
$idsstr = join(',', $ids);
$query = "select arc.*,tp.typedir,tp.typename,tp.corank,tp.isdefault,tp.defaultname,tp.namerule,
tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath
from jbxue_archives arc left join jbxue_arctype tp on arc.typeid=tp.id
where arc.id in($idsstr) $typeid order by arc.id desc";
}
else
{
$limitrow = $row - count($ids);
$keyword = '';
if(!empty($refobj->fields['keywords']))
{
$keywords = explode(',' , trim($refobj->fields['keywords']));
$keyword = '';
$n = 1;
foreach($keywords as $k)
{
if($n > 3) break;
if(trim($k)=='') continue;
else $k = addslashes($k);
$keyword .= ($keyword=='' ? " concat(arc.keywords,' ',arc.title) like '%$k%' " : " or concat(arc.keywords,' ',arc.title) like '%$k%' ");
$n++;
}
}
$arcid = (!empty($refobj->fields['id']) ? $refobj->fields['aid'] : 0);
if( empty($arcid) || $byabs==0 ) {
$orderquery = " order by arc.id desc ";
}
else {
$orderquery = " order by abs(arc.id - ".$arcid.") ";
}
if($keyword != '')
{
if(!empty($typeid)) {
$typeid = " and arc.typeid in($typeid) and arc.id<>$arcid ";
}
$query = "select arc.*,tp.typedir,tp.typename,tp.corank,tp.isdefault,tp.defaultname,tp.namerule,
tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath
from jbxue_archives arc left join jbxue_arctype tp on arc.typeid=tp.id
where arc.arcrank>-1 and ($keyword) $typeid $orderquery limit 0, $row";
}
else
{
if(!empty($typeid)) {
$typeid = " arc.typeid in($typeid) and arc.id<>$arcid ";
}
$query = "select arc.*,tp.typedir,tp.typename,tp.corank,tp.isdefault,tp.defaultname,tp.namerule,
tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath
from jbxue_archives arc left join jbxue_arctype tp on arc.typeid=tp.id
where arc.arcrank>-1 and $typeid $orderquery limit 0, $row";
}
}
}
$innertext = trim( $ctag->getinnertext() );
if($innertext=='') $innertext = getsystemplets('part_arclist.htm');
$dsql->setquery($query);
$dsql->execute('al');
$artlist = '';
if($col > 1) {
$artlist = "<table cellspacing='0' cellpadding='0'>\r\n";
}
$dtp2 = new dedetagparse();
$dtp2->setnamespace('field', '[', ']');
$dtp2->loadstring($innertext);
$globals['autoindex'] = 0;
$line = $row;
for($i=0; $i < $line; $i++)
{
if($col>1) $artlist .= "<tr>\r\n";
for($j=0; $j < $col; $j++)
{
if($col>1) $artlist .= " <td>\r\n";
if($row = $dsql->getarray("al"))
{
$ids[] = $row['id'];
//处理一些特殊字段
$row['info'] = $row['infos'] = cn_substr($row['description'],$infolen);
$row['id'] = $row['id'];
if($row['corank'] > 0 && $row['arcrank']==0)
{
$row['arcrank'] = $row['corank'];
}
$row['filename'] = $row['arcurl'] = getfileurl($row['id'],$row['typeid'],$row['senddate'],$row['title'],$row['ismake'],
$row['arcrank'],$row['namerule'],$row['typedir'],$row['money'],$row['filename'],$row['moresite'],$row['siteurl'],$row['sitepath']);
$row['typeurl'] = gettypeurl($row['typeid'],$row['typedir'],$row['isdefault'],$row['defaultname'],$row['ispart'],
$row['namerule2'],$row['moresite'],$row['siteurl'],$row['sitepath']);
if($row['litpic'] == '-' || $row['litpic'] == '')
{
$row['litpic'] = $globals['cfg_cmspath'].'/images/defaultpic.gif';
}
if(!eregi("^",$row['litpic']) && $globals['cfg_multi_site'] == 'y')
{
$row['litpic'] = $globals['cfg_mainsite'].$row['litpic'];
}
$row['picname'] = $row['litpic'];
$row['stime'] = getdatemk($row['pubdate']);
$row['typelink'] = "<a href='http://item.feedsky.com/~feedsky/simplc/~8543723/686077466/5696268/1/%22%3c/code%3e%3ccode%3e.%3c/code%3e%3ccode%3e$row%3c/code%3e%3ccode%3e['typeurl']."'>".$row['typename']."</a>";
$row['image'] = "<img src='http://item.feedsky.com/~feedsky/simplc/~8543723/686077466/5696268/1/%22%3c/code%3e%3ccode%3e.%3c/code%3e%3ccode%3e$row%3c/code%3e%3ccode%3e['picname']."' alt='".ereg_replace("['><]","",$row['title'])."'>";
$row['imglink'] = "<a href='http://item.feedsky.com/~feedsky/simplc/~8543723/686077466/5696268/1/%22%3c/code%3e%3ccode%3e.%3c/code%3e%3ccode%3e$row%3c/code%3e%3ccode%3e['filename']."'>".$row['image']."</a>";
$row['fulltitle'] = $row['title'];
$row['title'] = cn_substr($row['title'],$titlelen);
if($row['color']!='') $row['title'] = "<font color='".$row['color']."'>".$row['title']."</font>";
if(ereg('b',$row['flag'])) $row['title'] = "<strong>".$row['title']."</strong>";
$row['textlink'] = "<a href='http://item.feedsky.com/~feedsky/simplc/~8543723/686077466/5696268/1/%22%3c/code%3e%3ccode%3e.%3c/code%3e%3ccode%3e$row%3c/code%3e%3ccode%3e['filename']."'>".$row['title']."</a>";
$row['plusurl'] = $row['phpurl'] = $globals['cfg_phpurl'];
$row['memberurl'] = $globals['cfg_memberurl'];
$row['templeturl'] = $globals['cfg_templeturl'];
if(is_array($dtp2->ctags))
{
foreach($dtp2->ctags as $k=>$ctag)
{
if($ctag->getname()=='array') {
$dtp2->assign($k,$row);
}
else {
if(isset($row[$ctag->getname()])) $dtp2->assign($k,$row[$ctag->getname()]);
else $dtp2->assign($k,'');
}
}
$globals['autoindex']++;
}
$artlist .= $dtp2->getresult()."\r\n";
}
//if hasrow
else
{
$artlist .= '';
}
if($col>1) $artlist .= " </td>\r\n";
}
//loop col
if($col>1) $i += $col - 1;
if($col>1) $artlist .= " </tr>\r\n";
}
//loop line
if($col>1) $artlist .= " </table>\r\n";
$dsql->freeresult("al");
return $artlist;
}
?>

感谢您对【51运维网 http://www.51ou.com/】的支持,我们为您免费提供《织梦dedecms5.7全站怎么按tag与关键字调用相关文章?》技术文章,《织梦dedecms5.7全站怎么按tag与关键字调用相关文章?》详细使用和说明,有时《织梦dedecms5.7全站怎么按tag与关键字调用相关文章?》可能不完善、敬请谅解!如果《织梦dedecms5.7全站怎么按tag与关键字调用相关文章?》有错误请给我们留言,我们将尽快修复文章错误,如果您觉得本站不错,请分享给周围的朋友!谢谢!

顶一下
(0)
0%
踩一下
(0)
0%
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
验证码:点击我更换图片