方法一:
内容页的调用写法:
{dede:field.typeid2 runphp='yes'} global $dsql; $ks = split(',', @me); $tname=""; foreach($ks as $k){ $k = trim($k); if ($k!="") { if ($row = $dsql->getOne("select *,ID as id1 from dede_arctype where id=".$k)){ $mpath=GetTypeUrl($row['id1'],MfTypedir($row['typedir']),$row['isdefault'],$row['defaultname'],
$row['ispart'],$row['namerule2'],$row['siteurl']); $tname.="<span><a href='{$mpath}'>".$row['typename']."</a></span>"; } } } @me=substr($tname,0,strlen($tname)-1); {/dede:field.typeid2
首页、列表页标签(在arclist、list等文章列表标签里用): [field:typeid2 runphp='yes'] global $dsql; $ks = split(',', @me); $tname=""; foreach($ks as $k){ $k = trim($k); if ($k!="") { if ($row = $dsql->getOne("select *,ID as id1 from dede_arctype where id=".$k)){ $mpath=GetTypeUrl($row['id1'],MfTypedir($row['typedir']),$row['isdefault'],$row['defaultname'],$row['ispart'],
$row['namerule2'],$row['siteurl']); $tname.="<span><a href='{$mpath}'>".$row['typename']."</a></span>"; } } } @me=substr($tname,0,strlen($tname)-1); [/field:typeid2]
推荐用这种方法,不需要改东西就可以了。另外在网上看到另外一种方法,不过我没做测试,有兴趣的朋友可以试下。
方法二:
首先在 dedecms 目录下 /plus/ 新建文件 type_ajax.php 内容如下: <?php require_once(dirname(__FILE__)."/../include/common.inc.php"); $action = isset($action) ? trim($action) : ''; $id = (isset($id) && is_numeric($id)) ? $id : 0; if($id < 1) { exit(); } $maintable = "dede_archives"; $digg = ''; $row = $dsql->GetOne("Select * From dede_archives where id = '$id' "); $arr = split(",",$row['typeid2']); foreach ($arr as $key=>$type) { $namelist = $dsql->GetOne("Select * From dede_arctype where id = '$type' "); $digg .= '<a href=/plus/list.php?tid='.$type.'>'.$namelist['typename'].'<a>'." //"; } AjaxHead(); echo $digg; exit(); ?> dedecms 模板页调用 在<head>标记之间 加上 <script language="javascript" type="text/javascript" src="{dede:global.cfg_cmsurl/}/include/dedeajax2.js"></script> <script language="javascript" type="text/javascript"> <!-- function gettype(aid) { var taget_obj2 = document.getElementByIdx_x('newdigg2'); myajax2 = new DedeAjax(taget_obj2,false,false,'','',''); myajax2.SendPost2("{dede:global.cfg_phpurl/}/type_ajax.php?id="+aid); DedeXHTTP = null; } --> </script> <body>标记内加上
<span class="newdigg2" id="newdigg2">{dede:field.typeid2 /}</span><br /> <script language="javascript" type="text/javascript">gettype({dede:field.id/});</script> 其中<span>标记内的内容就是AJAX动态修改的内容。
以上信息由跟版网首发,转载请注明出处! 本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!