dedeCMS常用功能板块记忆

1、自动调到栏目第一个子栏目
<script>
  {dede:channel type='son' row='1'}
    window.location.href='[field:typelink /]';
  {/dede:channel}
</script>

 2、三级栏目判断示例

{dede:php}
$parentId = $refObj->Fields["topid"];
//判断是否是三级栏目
$row = $dsql->GetOne("select * from dede_arctype where id=".$parentId);
if($row['topid'] != 0){
  //有三级栏目
  $topid = $row['topid'];
}else{
  $topid = $parentId;
}
$dsql->SetQuery('select * from dede_arctype where topid='.$topid);
$dsql->Execute();
$rowNum = $dsql->GetTotalRow();
//var_dump($rowNum);
if($rowNum > 1){
  echo '<div class="h_sgbk">';
}else{
  echo '<div class="h_sgbk" style="display: none;">';
}
{/dede:php}

 3、首页判断

<a {dede:field name=typeid runphp="yes"}(@me=="")? @me=" class='hover'":@me="";{/dede:field} href="/">网站首页</a>

 4、判断是否是文章页面

if(isset($refObj->Fields['litpic'])) //有很多属性,随便判断一个

 5、调用自定义banner图

    {dede:php}
      $id = 9;
      $sql = "select imgstring from dede_banner where id = ".$id;
      $imgString = $dsql->GetOne("$sql");
      $imgArr = json_decode($imgString['imgstring']);
      $result = "";
      foreach($imgArr as $key=>$value){
        $result .= '<div class="swiper-slide"><img src="'.$cfg_custom_banner_upload_dir.'/'.$value.'"></div>';
      }
      echo $result;
      {/dede:php}
 

猜你喜欢

转载自www.cnblogs.com/linxingyun/p/9248522.html
今日推荐