Dedecms 文章列表动态调用

 

啥都不说了,这个页面就是用于ajax的,直接上代码,哈哈,喜欢的人到时候送我几个IP就行了

   1. <?php
   2. require_once(dirname(__FILE__)."/../include/common.inc.php");
   3. require_once(dirname(__FILE__)."/../include/channelunit.func.php");
   4.
   5.
   6.     foreach($_REQUEST as $k=>$v)
   7.     {
   8.         $$k=$v;
   9.     }
  10.    
  11.    
  12.     if (empty($order)) $order = "pubdate";
  13.     if (empty($orderway)) $orderway = "desc";
  14.     if (empty($rs_start)) $rs_start = 0;
  15.     if (empty($rs_end)) $rs_end = 10;
  16.    
  17.     $wherejoin = array();
  18.    
  19.     if (!empty($arcid)) $wherejoin[]= " arc.id in ($arcid) ";
  20.     if (!empty($tid)) $wherejoin[]=" arc.typeid=’$tid’ ";
  21.    
  22.     $wheresql = join(‘ and ‘,$wherejoin);
  23.     if (!empty($wheresql)) $wheresql="where " . $wheresql;
  24.    
  25.     if (empty($mod)) $mod=’static’;
  26.    
  27.    
  28.
  29.         $query = "Select arc.*,tp.typedir,tp.typename,tp.corank,tp.isdefault,tp.defaultname,tp.namerule,tp.namerule2,tp.ispart,
  30.             tp.moresite,tp.sitepath,tp.siteurl
  31.              from `dede_archives` arc left join `dede_arctype` tp on arc.typeid=tp.id
  32.              $wheresql order by $order $orderway limit $rs_start,$rs_end
  33.              ";
  34.
  35.    
  36.    
  37.     $dsql->SetQuery($query);
  38.     $dsql->Execute();
  39.    
  40.    
  41.     while($row = $dsql->GetArray())
  42.     {
  43.        
  44.             if ($mod==’static’)
  45.             {
  46.                
  47.                 $row['filename'] = $row['arcurl'] = GetFileUrl($row['id'],$row['typeid'],$row['senddate'],$row['title'],$row['ismake'],
  48.                 $row['arcrank'],$row['namerule'],$row['typedir'],$row['money'],$row['filename'],$row['moresite'],$row['siteurl'],$row['sitepath']);
  49.                
  50.                 $arcurl="{$row['filename']}";
  51.                
  52.             }
  53.            
  54.             else if ($mod==’dynamic’)
  55.             {
  56.                
  57.                 $arcurl="/plus/view.php?aid={$row['id']}";
  58.                
  59.             }
  60.        
  61.        
  62.         echo "<li><a href=’$arcurl’>{$row['title']}</a></li>";
  63.        
  64.        
  65.     }
  66. ?>

获取方法

网站最新文章10篇 /plus/typearc.php
网站最新文章20篇 /plus/typearc.php?rs_end=20
网站最新文章从第5条开始的10条记录 /plus/typearc.php?rs_start=5&rs_end=10
网站文章按照id顺序排列 /plus/typearc.php?order=id&orderway=asc
网站栏目id为8的最新文章10篇 /plus/typearc.php?tid=8
文章id为178和179的文章 /plus/typearc.php?arcid=178,179
获得静态的文章链接 /plus/typearc.php?mod=static
获取动态的文章链接 /plus/typearc.php?mod=dynamic

获取方法示例(jquery.ajax)

function gettypearc(id,Element){
    $.ajax({
   type: "POST",
   url: ‘plus/typearc.php’,
   data: ‘mod=dynamic&tid=’+id,
   success: function(html){
     $(Element).html(html);
   }
    });
}

<a href="javascript:" onclick="gettypearc(’8′,’type8′)">刷新文章列表</a>
<div id=’type8′>
{dede:arclist
…..
}
</div>

这样文章就能填充进来了

文章来自 dede论坛 作者liujin834