网页特效代码_站长素材站移动版

DeDecms教程

主页 > CMS教程 > DeDecms教程 >

织梦dedecms调用当前栏目TAG,调用指定栏目下面子集栏目TAG,指定栏目TAG的方法详解

列表页可以用下面这个:
    {dede:type}
   [field:id runphp=yes]
    $tsql2 = new DedeSql(false);
    $typelink2 = '';
    $tsql2->SetQuery("SELECT DISTINCT t.tag FROM dede_tagindex t, dede_taglist l WHERE t.id = l.tid AND l.typeid='@me' ORDER BY t.count DESC,t.addtime DESC LIMIT 0,40");
    $tsql2->Execute('t');
    while($row2 = $tsql2->GetArray('t',MYSQL_ASSOC))
    {           
    $typelink2 .= "<a href='/tags.php?/".$row2[' data-cke-saved-href='/tags.php?/".$row2[' data-cke-saved-href='/tags.php?/".$row2['tag']."' target=_blank>".$row2['tag']."</a>&nbsp;&nbsp;";           
    }
    @me = $typelink2;
   [/field:id]          
{/dede:type}  
 
频道或封面页必须用下面这种:需要指定当前栏目的ID,在新版里面支持,在老板dedecms里面不支持。
{dede:type}
   [field:id runphp=yes]     
    $tsql1 = new DedeSql(false);
    $stypeid = '';
    $typelink1 = '';
    $strSql1 = "SELECT id FROM dede_arctype WHERE reid='@me' ";
    $tsql1->SetQuery($strSql1);
    $tsql1->Execute('t1');
    while($row1 = $tsql1->GetArray('t1',MYSQL_ASSOC))
    {
     $stypeid .= 'l.typeid='.$row1['id'].'||'; 
     $stypeid .= typeall($row1['id']);
    }  
    if ($stypeid != ""){   
     @me = cn_substr($stypeid,strrpos($stypeid,'||'),0); 
    }else{
     @me = 'l.typeid='.@me;
    }  
    $numi = 0;         
    $strSql = "SELECT DISTINCT t.tag FROM dede_tagindex t,dede_taglist l WHERE t.id = l.tid AND ('@me') ORDER BY t.count DESC,t.addtime DESC LIMIT 0,40";
    $tsql1->SetQuery($strSql);
    $tsql1->Execute('t');
    while($row2 = $tsql1->GetArray('t',MYSQL_ASSOC))
    {     
     if ($numi == 0){
      $typelink1 .= "<li>";
      $typelink1 .= "<a class='rmbq_a' href='/tags.php?/".$row2[' data-cke-saved-href='/tags.php?/".$row2[' data-cke-saved-href='/tags.php?/".$row2['tag']."' target=_blank>".cn_substr($row2['tag'],6,0)."</a>";
     }else if($numi%5 == 0){
      $typelink1 .= "</li>";
      $typelink1 .= "<li>";
      $typelink1 .= "<a class='rmbq_a' href='/tags.php?/".$row2['tag']."' target=_blank>".cn_substr($row2['tag'],6,0)."</a>";
     }else{   
      $typelink1 .= "<a href='/tags.php?/".$row2['tag']."' target=_blank>".cn_substr($row2['tag'],5,0)."</a>"; 
     }       
     $numi = $numi + 1;   
    } 
   
    function typeall($reid=0){       
     $dbobj2 = new DedeSql(false);
     $strSql1 = "SELECT id FROM xingfu.yuer_arctype WHERE reid = $reid || topid=$reid";
     $dbobj2->SetQuery($strSql1);
     $dbobj2->Execute('f');
     while($row = $dbobj2->GetArray('f',MYSQL_ASSOC))
     { 
      $stypeid .= 'l.typeid='.$row['id'].'||';
        //结果赋值       
      typeall($row['id']);   
     } 
     return $stypeid;    
    }
    @me = $typelink1; 
   [/field:id]          
{/dede:type}
 
随机读取当前栏目的tag标签
{dede:type}
   [field:id runphp=yes]
    $tsql2 = new DedeSql(false);
    $typelink2 = '';
    $tsql2->SetQuery("SELECT * FROM dede_archives a LEFT JOIN dede_taglist t ON a.id=t.aid WHERE a.typeid=@me ORDER BY rand() LIMIT 0,14");
    $tsql2->Execute('t');
    while($row2 = $tsql2->GetArray('t',MYSQL_ASSOC))
    {           
    $typelink2 .= "<li><a href='/tags.php?/".$row2['tag']."' target=_blank>".$row2['tag']."</a></li>";           
    }
    @me = $typelink2;
   [/field:id]          
{/dede:type}
 
指定栏目读取
‍{dede:sql sql="select * from dede_archives a left join dede_taglist t on a.id=t.aid where a.typeid=2 limit 0,10 "}
<a href='/tags.php?[field:tag /]'>[field:tag /]</a>
{/dede:sql}

(责任编辑:admin)

    468x60