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

dedecms列表页调用评论数

 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]条评论

dedecms文章页调用评论数

 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}条评论
dedecms列表页好评与差评调用

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

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

 type="text/javascript" src="{dede:global.cfg_basehost/}/member/templets/js/j.js">
 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){}
转自: http://blog.zbusa.com/post-97.html

你可能感兴趣的:(织梦)