调用某人在某栏目下发的所有图片

技术交流17年前 (2007)发布
71 0

将此函数放在inc_functions.php下面就行了

function GetImage($writer,$lx,$num){

$dsql = new DedeSql(false);
$id=””;
//$dsql->SetQuery(“Select ID from dede_archives where writer='”.$writer.”‘ And typeid='”.$lx.”‘ order by sortrank asc”);
$dsql->SetQuery(“Select b.imgurls from dede_archives a,dede_addonimages b where a.writer='”.$writer.”‘ and a.id=b.aid and a.typeid='”.$lx.”‘ order by sortrank asc”);
$dsql->Execute();

while($row =$dsql->GetObject()){

$typeids[] = $row->imgurls;
$id.=$row->imgurls;

}
$dsql->Close();

$img=”;
$a=explode(“{/dede:img}”,$id);

for($i=0;$i{
while (strpos($a[$i],”}”)>0)
{
$a[$i]=substr($a[$i],strpos($a[$i],”}”)+1);

}

$img.=”调用某人在某栏目下发的所有图片“;
}

return $img;

}

调用的时候:
{dede:field name=’writer’ function=’GetImage(@me,44,4)’/}
field name=’writer’ :是某一位发稿人

GetImage:是函数名称;
44:是具体的栏目,比如张三在美女[typeID:44]下面发了10张图片
4:调用图片的张数,比如4张;

当然图片出来没有考虑排版,所以大家在页面写上一个CSS就行了,
如:

{dede:field name=’writer’ function=’GetImage(@me,44,4)’/}

css:
#hx{}
#hx img{
width:120px;
height:120px;
padding:10px;
margin:10px;}

© 版权声明

相关文章

暂无评论

暂无评论...