主页 > 建站教程 > 织梦教程 > 织梦文章页/列表页调用评论数、收藏数、好评、差评的sql语句

推荐下载

标签推荐

>> 更多

织梦文章页/列表页调用评论数、收藏数、好评、差评的sql语句

dedecms列表页调用评论数

 

<a href="[field:cfg_basehost/]/plus/feedback.php?aid=[field:id/]">
        [field:id runphp='yes'] $aid = @me; $row = $GLOBALS['dsql']->GetOne("Select count(id) as c from dede_feedback where aid=".@me); @me=$row['c'];[/field:id]条评论
</a>

dedecms列表页调用收藏数

 

<a href="[field:cfg_basehost/]/plus/feedback.php?aid=[field:id/]">
        [field:id runphp='yes'] $aid = @me; $row = $GLOBALS['dsql']->GetOne("Select count(id) as c from dede_member_stow where aid=".@me); @me=$row['c'];[/field:id]条评论
</a>

dedecms文章页调用评论数

 

<a href="{dede:field.cfg_basehost/}/plus/feedback.php?aid={dede:field.id/}">
    {dede:field.id runphp='yes'}
         $aid = @me; $row = $GLOBALS['dsql']->GetOne("Select count(id) as c from dede_feedback where aid=".@me); @me=$row['c'];
    {/dede:field.id}条评论
</a>
dedecms列表页好评与差评调用

 

<div class='good' title='好评' id="[field:id/]"> <span id='good[field:id/]'>好评:[field:goodpost/]</span> </div>
<div class='bad' title='差评' id="[field:id/]"> <span id='bad[field:id/]'>差评:[field:badpost/]</span> </div>
dedecms文章页好评调用

 

<div class='good' title='好评' id="{dede:field.id/}"> <span id='good{dede:field.id/}'>好评:{dede:field.goodpost/}</span> </div>
<div class='bad' title='差评' id="{dede:field.id/}"> <span id='bad{dede:field.id/}'>差评:{dede:field.badpost/}</span> </div>
如果想点击好评、差评起作用,加上下面的JS即可

 

<script type="text/javascript" src="{dede:global.cfg_basehost/}/member/templets/js/j.js"></script>
<script type="text/javascript">
  $(document).ready(function(){
    $("div[class*='good'],div[class*='bad']").bind("click", function(){
        var type = $(this).attr('class'),aid = $(this).attr('id');
        var saveId = getCookie('diggid');
        if(saveId != null)
        {
            var saveIds = saveId.split(',');
            var hasId = false;
            j = 1;saveId = '';
            for(i=saveIds.length-1;i>=0;i--)
            {
                if(saveIds[i]==aid && hasId) continue;
                else
                {
                    if(saveIds[i]==aid && !hasId) hasId = true;
                    saveId += (saveId=='' ? saveIds[i] : ','+saveIds[i]);
                    j++;
                    if(j==20 && hasId) break;
                    if(j==19 && !hasId) break;
                }
            }
            
            if(hasId) { alert("您已经顶过该帖,请不要重复顶帖 !"); return false; }
            else saveId += ','+aid;
            setCookie('diggid',saveId,1);
        }
        else
        {
            setCookie('diggid',aid,1);
        }        
        $.ajax({type: 'POST',url: "{dede:global.cfg_basehost/}/plus/feedback.php",
            data: "formurl=caicai&action="+type+"&aid="+aid,
            dataType: 'text',
            success: function(result){$("#"+type+aid).html(result);}
        });
        
    });
});
//读写cookie函数
function getCookie(c_name)
{
    if (document.cookie.length > 0)
    {
        c_start = document.cookie.indexOf(c_name + "=")
        if (c_start != -1)
        {
            c_start = c_start + c_name.length + 1;
            c_end   = document.cookie.indexOf(";",c_start);
            if (c_end == -1)
            {
                c_end = document.cookie.length;
            }
            return unescape(document.cookie.substring(c_start,c_end));
        }
    }
    return null
}
function setCookie(c_name,value,expiredays)
{
    var exdate = new Date();
    exdate.setDate(exdate.getDate() + expiredays);
    document.cookie = c_name + "=" +escape(value) + ((expiredays == null) ? "" : ";expires=" + exdate.toGMTString()); //使设置的有效时间正确。增加toGMTString()
}
function postBadGood(type,id){}
</script>