在织梦DEDECMS系统中,默认情况下会员在评论时只能选择一个表情,这在一定程度上限制了评论的表达力和丰富性,为了提高用户体验,使评论更加生动有趣,可以通过简单的代码修改实现会员评论时添加多个表情的功能,以下是具体步骤:
第一步:修改feedback_ajax.php文件
1、定位文件:找到并打开位于根目录下plus
文件夹中的feedback_ajax.php
文件。
2、插入代码:在该文件中查找以下代码:
“`php
if($dopost==’getlist’)
“`
在这段代码的上面插入以下代码:
“`php
function convertem($message){
$a = array(‘[em01]’,'[em02]’,'[em03]’,'[em04]’,'[em05]’,'[em06]’,'[em07]’,'[em08]’,'[em09]’,'[em10]’,'[em11]’,'[em12]’,'[em13]’,'[em14]’,'[em15]’,'[em16]’,'[em17]’,'[em18]’,'[em19]’,'[em20]’,'[em21]’,'[em22]’,'[em23]’,'[em24]’);
$b = array(‘<img src="../../../images/mood/icomood1.gif" />’,'<img src="../../../images/mood/icomood2.gif" />’,'<img src="../../../images/mood/icomood3.gif" />’,'<img src="../../../images/mood/icomood4.gif" />’,'<img src="../../../images/mood/icomood5.gif" />’,'<img src="../../../images/mood/icomood6.gif" />’,'<img src="../../../images/mood/icomood7.gif" />’,'<img src="../../../images/mood/icomood8.gif" />’,'<img src="../../../images/mood/icomood9.gif" />’,'<img src="../../../images/mood/icomood10.gif" />’,'<img src="../../../images/mood/icomood11.gif" />’,'<img src="../../../images/mood/icomood12.gif" />’,'<img src="../../../images/mood/icomood13.gif" />’,'<img src="../../../images/mood/icomood14.gif" />’,'<img src="../../../images/mood/icomood15.gif" />’,'<img src="../../../images/mood/icomood16.gif" />’,'<img src="../../../images/mood/icomood17.gif" />’,'<img src="../../../images/mood/icomood18.gif" />’,'<img src="../../../images/mood/icomood19.gif" />’,'<img src="../../../images/mood/icomood20.gif" />’,'<img src="../../../images/mood/icomood21.gif" />’,'<img src="../../../images/mood/icomood22.gif" />’,'<img src="../../../images/mood/icomood23.gif" />’,'<img src="../../../images/mood/icomood24.gif" />’);
$message = str_replace($a,$b,$message);
return $message;
}
“`
这一步的作用是将文本中的表情标签替换为相应的图片标签,从而实现表情的显示。
第二步:修改ajaxfeedback.htm文件
1、定位文件:找到并打开位于模板目录(默认路径为templets/default/ajaxfeedback.htm
)下的ajaxfeedback.htm
文件。
2、替换代码:在该文件中找到以下代码段:
“`html
<div class="dcmpmood">
<!这里通常会有一组Li元素,每个Li包含一个表情 >
</div>
“`
将其中的<ul>
和<li>
元素替换为以下代码:
“`html
<img src="{dede:global.cfg_cmsurl/}/images/mood/icomood1.gif" onclick="javascript:document.getElementById(‘msg’).value+='[em01]’;" />
<img src="{dede:global.cfg_cmsurl/}/images/mood/icomood2.gif" onclick="javascript:document.getElementById(‘msg’).value+='[em02]’;" />
<img src="{dede:global.cfg_cmsurl/}/images/mood/icomood3.gif" onclick="javascript:document.getElementById(‘msg’).value+='[em03]’;" />
<img src="{dede:global.cfg_cmsurl/}/images/mood/icomood4.gif" onclick="javascript:document.getElementById(‘msg’).value+='[em04]’;" />
<img src="{dede:global.cfg_cmsurl/}/images/mood/icomood5.gif" onclick="javascript:document.getElementById(‘msg’).value+='[em05]’;" />
<img src="{dede:global.cfg_cmsurl/}/images/mood/icomood6.gif" onclick="javascript:document.getElementById(‘msg’).value+='[em06]’;" />
<img src="{dede:global.cfg_cmsurl/}/images/mood/icomood7.gif" onclick="javascript:document.getElementById(‘msg’).value+='[em07]’;" />
<img src="{dede:global.cfg_cmsurl/}/images/mood/icomood8.gif" onclick="javascript:document.getElementById(‘msg’).value+='[em08]’;" />
<img src="{dede:global.cfg_cmsurl/}/images/mood/icomood9.gif" onclick="javascript:document.getElementById(‘msg’).value+='[em09]’;" />
<img src="{dede:global.cfg_cmsurl/}/images/mood/icomood10.gif" onclick="javascript:document.getElementById(‘msg’).value+='[em10]’;" />
<img src="{dede:global.cfg_cmsurl/}/images/mood/icomood11.gif" onclick="javascript:document.getElementById(‘msg’).value+='[em11]’;" />
<img src="{dede:global.cfg_cmsurl/}/images/mood/icomood12.gif" onclick="javascript:document.getElementById(‘msg’).value+='[em12]’;" />
<img src="{dede:global.cfg_cmsurl/}/images/mood/icomood13.gif" onclick="javascript:document.getElementById(‘msg’).value+='[em13]’;" />
<img src="{dede:global.cfg_cmsurl/}/images/mood/icomood14.gif" onclick="javascript:document.getElementById(‘msg’).value+='[em14]’;" />
<img src="{dede:global.cfg_cmsurl/}/images/mood/icomood15.gif" onclick="javascript:document.getElementById(‘msg’).value+='[em15]’;" />
<img src="{dede:global.cfg_cmsurl/}/images/mood/icomood16.gif" onclick="javascript:document.getElementById(‘msg’).value+='[em16]’;" />
<img src="{dede:global.cfg_cmsurl/}/images/mood/icomood17.gif" onclick="javascript:document.getElementById(‘msg’).value+='[em17]’;" />
<img src="{dede:global.cfg_cmsurl/}/images/mood/icomood18.gif" onclick="javascript:document.getElementById(‘msg’).value+='[em18]’;" />
<img src="{dede:global.cfg_cmsurl/}/images/mood/icomood19.gif" onclick="javascript:document.getElementById(‘msg’).value+='[em19]’;" />
<img src="{dede:global.cfg_cmsurl/}/images/mood/icomood20.gif" onclick="javascript:document.getElementById(‘msg’).value+='[em20]’;" />
<img src="{dede:global.cfg_cmsurl/}/images/mood/icomood21.gif" onclick="javascript:document.getElementById(‘msg’).value+='[em21]’;" />
<img src="{dede:global.cfg_cmsurl/}/images/mood/icomood22.gif" onclick="javascript:document.getElementById(‘msg’).value+='[em22]’;" />
<img src="{dede:global.cfg_cmsurl/}/images/mood/icomood23.gif" onclick="javascript:document.getElementById(‘msg’).value+='[em23]’;" />
<img src="{dede:global.cfg_cmsurl/}/images/mood/icomood24.gif" onclick="javascript:document.getElementById(‘msg’).value+='[em24]’;" />
“`
这样,当用户点击这些表情图片时,就会在评论输入框中插入对应的表情标签,从而实现多表情功能。
通过以上两个步骤的修改,DEDECMS系统的评论功能就可以支持会员在评论时添加多个表情,使得评论内容更加丰富多彩、生动有趣,希望这篇文章能够帮助你顺利实现这一功能,如果有任何疑问或需要进一步的帮助,请随时联系我。
原创文章,作者:未希,如若转载,请注明出处:https://www.kdun.com/ask/1102705.html
本网站发布或转载的文章及图片均来自网络,其原创性以及文中表达的观点和判断不代表本网站。如有问题,请联系客服处理。
发表回复