dedecms在单页里调用产品点评
按理说你复制来的代码应该是有效的,看代码调用了一个javascript方法,是不是javascript文件没有加载完整?
这是我调用的方法:
HTML部分:
<div class="newdigg" id="newdigg"><div class="diggbox digg_good" onmousemove="thisstylebackgroundPosition='left bottom';" onmouseout="thisstylebackgroundPosition='left top';" onclick="javascript:postDigg('good',38)">
<div class="digg_act">顶一下</div>
<div class="digg_num">(0)</div>
<div class="digg_percent">
<div class="digg_percent_bar"><span style="width:0%"></span></div>
<div class="digg_percent_num">0%</div>
</div>
</div>
<div class="diggbox digg_bad" onmousemove="thisstylebackgroundPosition='right bottom';" onmouseout="thisstylebackgroundPosition='right top';" onclick="javascript:postDigg('bad',38)">
<div class="digg_act">踩一下</div>
<div class="digg_num">(0)</div>
<div class="digg_percent">
<div class="digg_percent_bar"><span style="width:0%"></span></div>
<div class="digg_percent_num">0%</div>
</div>
</div>
</div>
<script language="javascript">getDigg(38);</script>
JS部分:
function postDigg(ftype,aid){
var taget_obj = documentgetElementById('newdigg');
var saveid = GetCookie('diggid');
if(saveid != null)
{
var saveids = saveidsplit(',');
var hasid = false;
saveid = '';
j = 1;
for(i=saveidslength-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; }
else saveid += ','+aid;
SetCookie('diggid',saveid,1);
}
else
{
SetCookie('diggid',aid,1);
}
myajax = new DedeAjax(taget_obj,false,false,'','','');
var url = "/plus/digg_ajaxphpaction="+ftype+"&id="+aid;
myajaxSendGet2(url);
DedeXHTTP = null;
}
function getDigg(aid)
{
var taget_obj = documentgetElementById('newdigg');
myajax = new DedeAjax(taget_obj,false,false,'','','');
myajaxSendGet2("/plus/digg_ajaxphpid="+aid);
DedeXHTTP = null;
}
确保加载了JS文件:
<script language="javascript" type="text/javascript" src="/include/dedeajax2js"></script>
具体方法如下:
1、DedeCMS默认风格里,顶部左边有一段话"织梦CMS - 轻松建站从此开始!",很多朋友想把这段话修改成一个横向登录框,像织梦吧(dedecms8com)顶部一样。
2、打开头部公用模板文件templets/default/headhtm,找到如下汉字:
3、把上图里汉字,替换为如下代码:
<div id="_userlogin">
<form name="userlogin" action="{dede:globalcfg_memberurl/}/index_dophp" method="POST">
<input type="hidden" name="dopost" value="login" />
<span>用户名:</span>
<input type="text" name="userid" size="10" class="ipt-txt" />
<span>密码:</span>
<input type="密码" name="pwd" size="10" class="ipt-txt" />
{dede:php}
if(preg_match("#2#", $safe_gdopen)){
echo '
<span>验证码:</span>
<input type="text" name="vdcode" size="8" class="ipt-txt" />
<img id="vdimgck" align="absmiddle" style="cursor:pointer;margin-left:0px;text-transform:uppercase;" alt="看不清?点击更换" src="'$cfg_cmspath'/include/vdimgckphp"/>';}
{/dede:php}
<button type="submit" class="btn-1">登录</button>
<a href="{dede:globalcfg_memberurl/}/index_dophpfmdo=user&dopost=regnew" >注册账号</a> <a href="{dede:globalcfg_memberurl/}/reset密码php">忘记密码</a>
</form>
</div>
<script language="javascript" type="text/javascript">CheckLogin();</script>
改后:
4、其实仅仅这段代码还不够,还需要完成下一步才能达到效果:
那么,我这里为什么没有加这段代码呢这是因为默认主页模板文件indexhtm里,已经包涵了这段代码。如果没有,或被自己删除了,请添加在indexhtm里之前。
打开member/ajax_loginstaphp文件,找到如下代码
5、上图红色框内的代码,即为登录成功后,返回用户信息。多数时候,我们的顶部导航没太宽的地方,以显示这些数据,所有完全没必要全部返回这些信息,可以适当减少几项,并且对div做美化,以达到美观体验。这里,简单做下调整,如下:
6、更新生成后,可以看到如下效果:
这样一个顶部横向登录框就制作完了。
其实可以不用dede自带的评论模块,因为会有漏洞,易被黑客利用。有很多免费的文章评论系统比如使用《多说》,几行代码就可以搞定。
下面是dede评论提交框
<a name='postform'></a><div class="mt1">
<dl class="pbox">
<dt>
<strong>发表评论</strong>
<span class="more"></span>
</dt>
<dd>
<div class="dede_comment_post">
<form action="#" method="post" name="feedback">
<input type="hidden" name="dopost" value="send" />
<input type="hidden" name="comtype" value="comments">
<input type="hidden" name="aid" value="{dede:field name="id"/}" />
<input type="hidden" name="fid" id='feedbackfid' value="0" />
<div class="userface" id="_userface">
<a href="/member/indexphp" class="plpic" target="_blank"><img src="/member/templets/images/dfboypng" width="50" height="50" /></a>
</div><script language="javascript" type="text/javascript">CheckLoginface();</script>
<div class="dcmp-stand">
<strong>评价:</strong>
<input type="radio" name="feedbacktype" checked="1" value="feedback" id="dcmp-stand-neu" /><label for="dcmp-stand-neu"><img src="{dede:globalcfg_templets_skin/}/images/cmt-neugif" />中立</label>
<input type="radio" name="feedbacktype" value="good" id="dcmp-stand-good" /><label for="dcmp-stand-good"><img src="{dede:globalcfg_templets_skin/}/images/cmt-goodgif" />好评</label>
<input type="radio" name="feedbacktype" value="bad" id="dcmp-stand-bad" /><label for="dcmp-stand-bad"><img src="{dede:globalcfg_templets_skin/}/images/cmt-badgif" />差评</label>
</div><!-- /dcmp-stand -->
<div class="clr"></div>
<div class="dcmp-mood">
<ul>
<li><input type="radio" name="face" value="1" /><img src="{dede:globalcfg_templets_skin/}/images/mood/ico-mood-1gif" /></li>
<li><input type="radio" name="face" value="2"/><img src="{dede:globalcfg_templets_skin/}/images/mood/ico-mood-2gif" /></li>
<li><input type="radio" name="face" value="3"/><img src="{dede:globalcfg_templets_skin/}/images/mood/ico-mood-3gif" /></li>
<li><input type="radio" name="face" value="4"/><img src="{dede:globalcfg_templets_skin/}/images/mood/ico-mood-4gif" /></li>
<li><input type="radio" name="face" value="5"/><img src="{dede:globalcfg_templets_skin/}/images/mood/ico-mood-5gif" /></li>
<li><input type="radio" name="face" value="6"/><img src="{dede:globalcfg_templets_skin/}/images/mood/ico-mood-6gif" /></li>
<li><input type="radio" name="face" value="7"/><img src="{dede:globalcfg_templets_skin/}/images/mood/ico-mood-7gif" /></li>
<li><input type="radio" name="face" value="8"/><img src="{dede:globalcfg_templets_skin/}/images/mood/ico-mood-8gif" /></li>
<li><input type="radio" name="face" value="9"/><img src="{dede:globalcfg_templets_skin/}/images/mood/ico-mood-9gif" /></li>
<li><input type="radio" name="face" value="10"/><img src="{dede:globalcfg_templets_skin/}/images/mood/ico-mood-10gif" /></li>
<li><input type="radio" name="face" value="11"/><img src="{dede:globalcfg_templets_skin/}/images/mood/ico-mood-11gif" /></li>
<li><input type="radio" name="face" value="12"/><img src="{dede:globalcfg_templets_skin/}/images/mood/ico-mood-12gif" /></li>
</ul>
</div><!-- /dcmp-mood -->
<div class="dcmp-content">
<textarea cols="60" name="msg" rows="5" class="ipt-txt" style="width:700px"></textarea>
</div><!-- /dcmp-content -->
<div class="dcmp-post"><!--未登陆-->
<div class="dcmp-userinfo" id="_ajax_feedback">
{dede:php}
if($cfg_mb_open=='Y') {
echo '用户名:<input type="text" name="username" size="10" class="ipt-txt" />
密码:<input name="pwd" type="password" id="pwd" size="10" class="ipt-txt" />';
}
{/dede:php}
验证码:<input type='text' name='validate' size='4' class='ipt-txt' style="text-transform:uppercase;"/><img src="{dede:globalcfg_cmsurl /}/include/vdimgckphp" id="validateimg" style="cursor:pointer" onclick="thissrc=thissrc+''" title="点击我更换" alt="点击我更换" />
</div>
{dede:php}
if($cfg_mb_open=='Y') {
echo '<script language="javascript" type="text/javascript">CheckLogin();</script>';
}
{/dede:php}
<div class="dcmp-submit">
<button type="button" class="btn-2" onClick='PostComment()'>发表评论</button>
</div>
</div>
</form>
</div>
</dd>
</dl>
</div><!-- //评论表单区结束 -->
0条评论