首页  »  站长资讯  »  网站优化

织梦dedecms图集图片每张自定义输出不同样式

2023/03/11 12:21     创新屋收录网     已浏览339次






如果你的图集图片要在内容页按不同的html输出每一张图片,出了CSS+js能实现,我们也可以用array runphp的方式来让每一张自定义输出



效果



修改教程



includetaglibproductimagelist.lib.php 找到



foreach($images as $row)



{



中间省略...



}



改成



$GLOBALS['autoindex'] = 1;
foreach($images as $row)
{
$row['autoindex'] =  $GLOBALS['autoindex'];
foreach($ctp->CTags as $tagid=>$ctag)
{
if($ctag->GetName()=='array')
{
$ctp->Assign($tagid,$row);
}
else
{
if(isset($row[$ctag->GetName()])){ $ctp->Assign($tagid,$row[$ctag->GetName()]); }
}
}
$revalue .= $ctp->GetResult();
$GLOBALS['autoindex']++;
}


内容页图集标签



{dede:productimagelist}
[field:array runphp=yes]
if(@me['autoindex'] == 1)
{
@me = "{@me['autoindex']} - n";
}
elseif(@me['autoindex'] == 2)
{
@me = "

{@me['autoindex']} - 

n";
}
elseif(@me['autoindex'] == 3)
{
@me = "{@me['autoindex']} - n";
}
else
{
@me = "
{@me['autoindex']} - 
n";
}
[/field:array]
{/dede:productimagelist}


 



 



复杂一点的写法




{dede:productimagelist}
[field:array runphp=yes]
if(@me['autoindex'] == 2)
{

@me = "
  ";
}
else
{
@me = "";
}
[/field:array]
{/dede:productimagelist}

{dede:productimagelist}
[field:array runphp=yes]
if(@me['autoindex'] == 3)
{

@me = "
 
";
}
elseif(@me['autoindex'] == 4)
{

@me = "
 
";
}
else
{
@me = "";
}
[/field:array]
{/dede:productimagelist}