织梦二级栏目调用顶级栏目下的文章列表

今天一个朋友问我,二级栏目调用顶级栏目下的文章列表,说百度一些全都是调用顶级栏目名称的一些方法。

在/include/com.func.php中 添加一个方法

//获取顶级栏目名 by 蜗牛
function GetTopTypename($id)
{
global $dsql;
$row = $dsql->GetOne(“SELECT typename,topid FROM jiemou_arctype WHERE id= $id”);
if ($row[‘topid’] == ‘0’)
{
return $row[‘typename’];
}
else
{
$row1 = $dsql->GetOne(“SELECT typename FROM jiemou_arctype WHERE id= $row[topid]”);
return $row1[‘typename’];
}
}

/*调用顶级栏目文章列表 by 蜗牛*/
function Getcontent($typeid)
{
global $dsql;
include_once(DEDEINC.”/channelunit.func.php”);
$typeid = trim(preg_replace(‘/[^0-9]/’, ”, $typeid));
$row = $dsql->GetOne(“SELECT topid FROM `sj_arctype` WHERE id= $typeid”);
$topid = $row[‘topid’];
if($topid==’0′)
{
$query = “SELECT a.id, a.title, a.typeid, a.senddate, a.ismake, a.arcrank, a.money, m.moresite, a.filename, m.siteurl, m.sitepath, m.namerule, m.typedir, m.moresite, m.siteurl FROM `sj_archives` as a left join `sj_arctype` as m on m.id = a.typeid WHERE a.typeid=”.$typeid;
$dsql->Execute(‘content’,$query);
while($arr = $dsql->GetArray(‘content’))
{
$arcurl = GetFileUrl($arr[‘id’], $arr[‘typeid’], $arr[‘senddate’], $arr[‘title’],
$arr[‘ismake’], $arr[‘arcrank’], $arr[‘namerule’], $arr[‘typedir’],
$arr[‘money’], $arr[‘filename’], $arr[‘moresite’], $arr[‘siteurl’],
$arr[‘sitepath’]);
$title .= ”

 

“;
}
}
else
{
$query = “SELECT a.id, a.title, a.typeid, a.senddate, a.ismake, a.arcrank, a.money, m.moresite, a.filename, m.siteurl, m.sitepath, m.namerule, m.typedir, m.moresite, m.siteurl FROM `sj_archives` as a left join `sj_arctype` as m on m.id = a.typeid WHERE typeid=”.$topid;
$dsql->Execute(‘content’,$query);
while($arr = $dsql->GetArray(‘content’))
{
$arcurl = GetFileUrl($arr[‘id’], $arr[‘typeid’], $arr[‘senddate’], $arr[‘title’],
$arr[‘ismake’], $arr[‘arcrank’], $arr[‘namerule’], $arr[‘typedir’],
$arr[‘money’], $arr[‘filename’], $arr[‘moresite’], $arr[‘siteurl’],
$arr[‘sitepath’]);
$title .= ”

 

“;
}

return $title;
}
}

然后呢 在列表模板中
{dede:field name=’typeid’ function=”Getcontent(@me)” /}
这样调用就可以了奥

Related Posts Plugin for WordPress, Blogger...