很多時候,我們需要在頁面調用評論數和收藏數,織夢dede默認是不支持動態調用評論數和收藏數的,只能自己動手,現在和大家分享實現動態調用評論
數和收藏數的方法。
1、首先在根目錄plus/文件下創建文件名為fedcount.php的php頁面,將下面的代碼粘貼進去,記得修改數據庫前綴名
document.write("<?php require_once(dirname(__FILE__)."/../include/common.inc.php");
$row = $db->GetOne("select count(*) as fc from dede_feedback where aid='{$aid}' ");
if(!is_array($row))
{
echo "0";
}
else
{
echo $row['fc'];
}
?>");
2、在需要放置評論數的位置,調用下面的js代碼即可
<script type="text/javascript" src="{dede:field name='phpurl'/}/fedcount.php?aid={dede:field.id/}"></script>
3、把下面的代碼保存為fedccount.php,記得修改數據庫前綴名
document.write("<?php require_once(dirname(__FILE__)."/../include/common.inc.php");
$row = $db->GetOne("select count(*) as c from dede_member_stow where aid='{$aid}' ");
if(!is_array($row))
{
echo "0";
}
else
{
echo $row['c'];
}
?>");
4、在需要放置評論數的位置,調用下面的js代碼即可
<script type="text/javascript" src="{dede:field name='phpurl'/}/fedccount.php?aid={dede:field.id/}"></script>