网站地图    收藏   

主页 > 前端 > css教程 >

修改dede5.7 ask源码标签 使之实现--->调用相应级

来源:自学PHP网    时间:2015-04-14 14:50 作者: 阅读:

[导读] 修改dede5.7 ask源码标签 使之实现---调用相应级别[一级,二级,...栏目]的问答,可根据需要修改/include/asks.lib.php01?php if(!defined(#39;DEDEINC#39;)) exit(#39;Request Error!#39;);02/**03* 问......

修改dede5.7 ask源码标签 使之实现--->调用相应级别[一级,二级,...栏目]的问答,可根据需要修改

/include/asks.lib.php

01
<?php if(!defined('DEDEINC')) exit('Request Error!');
02
/**
03
 * 问答调用标签
04
 *
05
 * @version        $Id: ask.lib.php 1 9:29 2010年7月6日Z tianya $
06
 * @package        DedeCMS.Taglib
07
 * @copyright       Copyright (c) 2007 - 2010, DesDev, Inc.
08
 * @license         http://help.dedecms.com/usersguide/license.html
09
 * @link            http://www.dedecms.com
10
 */
11
function lib_asks(&$ctag,&$refObj)
12
{
13
    global $dsql, $envs, $cfg_dbprefix, $cfg_cmsurl,$cfg_ask_directory,$cfg_ask_isdomain,$cfg_ask_domain;
14
    //属性处理
15
    $attlist="row|6,qtype|new,titlelen|24,typeid|0";
16
    FillAttsDefault($ctag->CAttribute->Items,$attlist);
17
    extract($ctag->CAttribute->Items, EXTR_SKIP);
18
    
19
    if( !$dsql->IsTable("{$cfg_dbprefix}ask") ) return '没安装问答模块';
20
    
21
    //启用二级域名
22
    if($cfg_ask_isdomain == 'Y')
23
    {
24
        $weburl = $cfg_ask_domain.'/';
25
    }else{
26
        $weburl = $cfg_ask_directory.'/';
27
    }
28
    
29
    $innertext = $ctag->GetInnerText();
30
    if(trim($innertext)=='') $innertext = GetSysTemplets("asks.htm");
31
    
32
    if($typeid==0) {
33
        $typeid = ( isset($refObj->TypeLink->TypeInfos['id']) ? $refObj->TypeLink->TypeInfos['id'] : $envs['typeid'] );
34
    }
35
    
36
    $arc=$dsql->GetOne("Select id,topid,typename From `detest_arctype` where id='$typeid' ");
37
    $topid=$arc['topid'];
38
    $typename=$arc['typename'];
39
    
40
    if($topid==0){
41
        $arcs=$dsql->GetOne("SELECT tid,tid2 FROM `detest_ask` where tidname='$typename' ");
42
        $tid=$arcs['tid'];
43
    }else{
44
        $arcs=$dsql->GetOne("SELECT tid,tid2 FROM `detest_ask` where tid2name='$typename' ");
45
        $tid=$arcs['tid2'];
46
    }
47
    
48
    $qtypeQuery = '';
49
    if($tid > 0) $tid = " (tid=$tid Or tid2='$tid') AND ";
50
    else $tid = '';
51
    //推荐问题
52
    if($qtype=='commend') $qtypeQuery = " $tid digest=1 ORDER BY dateline DESC ";
53
    //新解决问题
54
    else if($qtype=='ok') $qtypeQuery = " $tid status=1 ORDER BY solvetime DESC ";
55
    //高分问题
56
    else if($qtype=='high') $qtypeQuery = " $tid status=0 ORDER BY reward DESC ";
57
    //新问题
58
    else $qtypeQuery = " $tid status=0 ORDER BY disorder DESC, dateline DESC ";
59
 
60
    $ctp = new DedeTagParse();
61
    $ctp->SetNameSpace('field', '[', ']');
62
 
63
    $solvingask = '';
64
    $query = "SELECT id, tid, tidname, tid2, tid2name, title, content, dateline FROM `detest_ask` WHERE $qtypeQuery  limit 0, $row";
65
    $dsql->Execute('me',$query);
66
    
67
    while($rs = $dsql->GetArray('me'))
68
    {
69
        $rs['title'] = cn_substr($rs['title'], $titlelen);
70
        $rs['content'] = strip_tags($rs['content']);
71
        $ctp->LoadSource($innertext);
72
        if($rs['tid2name'] != '')
73
        {
74
            $rs['tid'] = $rs['tid2'];
75
            $rs['tidname'] = $rs['tid2name'];
76
        }
77
        //$rs['url'] = $weburl."?ct=question&askaid=".$rs['id'];
78
        $rs['url'] = $weburl.$rs['id'].'.html';
79
        foreach($ctp->CTags as $tagid=>$ctag) {
80
            if(!empty($rs[strtolower($ctag->GetName())])) {
81
                $ctp->Assign($tagid,$rs[$ctag->GetName()]);
82
            }
83
        }
84
        $solvingask .= $ctp->GetResult();
85
    }
86
    return $solvingask;
87
}
模板调用---->去掉了 tid='0'

{dede:ask row='6' qtype='new'  titlelen='24'}
<dd>
    <span>[<a href='[field:typeurl/]'>[field:tidname/]</a>]</span>
    <span><a href="[field:url/]">[field:title/]</a></span>
</dd>{/dede:ask}

 

作者:bug哥

自学PHP网专注网站建设学习,PHP程序学习,平面设计学习,以及操作系统学习

京ICP备14009008号-1@版权所有www.zixuephp.com

网站声明:本站所有视频,教程都由网友上传,站长收集和分享给大家学习使用,如由牵扯版权问题请联系站长邮箱904561283@qq.com

添加评论