微新闻功能介绍:
微新闻即短小的新闻新闻,像新鲜事,微博一样.
功能有:用户通过即时窗口发布,其他用户可以在第一条微新闻下的直接进行回复评论.
在UCHOME中添加功能具体方法如下:
1、建立发布微新闻的页面:
以下是发布微新闻的发布框,可用更新个人签名的模块来修改,称为页面a.html:
- <div id="mood_wxwform">
- <form method="post" action="cp.php?ac=mnews" id="mood_addwxwform">
- <div id="mood_statusinput_wxw" class="statusinput_wxw"><textarea name="message" id="mood_message_wxw" onclick="statusFace();" onkeydown="if(event.keyCode == 13 ){ event.returnValue=false;event.cancel = true;$('mood_add_wxw').click();$('mood_message_wxw').value='';this.blur(); };" >你可以在这里发布你相关的所见所闻,分享给大家!</textarea></div>
- <div class="statussubmit_wxw">
- <input type="button" id="mood_add_wxw" name="add_wxw" value="发布" class="submit" style="display:block;" onclick="ajaxpost('mood_addwxwform', 'reloadMood');$('mood_message_wxw').value='';" />
- <input type="hidden" name="addsubmit" value="true" />
- <input type="hidden" name="spacenote" value="true" />
- <input type="hidden" name="formhash" value="<!--{eval echo formhash();}-->" />
- </div>
- </form>
- </div>
a.html显示微新闻部分:
- <div id="mood_mystatus_wxw">
- <!--{if $wxwlist}-->
- <!--{loop $wxwlist $r}-->
- <table style="width:620px; margin-top:10px;"><tr><td style="vertical-align:top; padding-top:5px; width:50px;"><!--{avatar($_SGLOBAL[supe_uid],small)}--></td>
- <td style="vertical-align:top; padding-left:10px;">
- <div style="height:auto; font-size:14px; color:#617d80; line-height:22px;"><span style="color:#124a83; font-weight:bold;">$r[username]</span>:$r[message]</div>
- <br/>
- <div style="height:25px; font-size:12px; color:#617d80; list-style:22px;">
- <!--{if emptyempty($_TPL[hidden_time])}-->
- <span class="gray"><!--{date('m-d H:i',$r[dateline],1)}--></span>
- <!--{/if}-->
- </div>
- </td></tr></table>
- <!--{/loop}-->
- <!--{if $count==$perpage}-->
- <div class="page" style="padding-top:20px;">
- <a href="javascript:;" onclick="getmore();" id="a_feed_more">查看更多动态</a>
- </div>
- <!--{/if}-->
- <!--{/if}-->
- </div>
- <div id="friendswxw" style="display:none;">
- <!--{if $friendwxwlist}-->
- <!--{loop $friendwxwlist $r}-->
- <table style="width:620px; margin-top:10px;"><tr><td style="vertical-align:top; padding-top:5px; width:50px;"><!--{avatar($_SGLOBAL[supe_uid],small)}--></td>
- <td style="vertical-align:top; padding-left:10px;">
- <div style="height:auto; font-size:14px; color:#617d80; line-height:22px;"><span style="color:#124a83; font-weight:bold;">$r[username]</span>:$r[message]</div>
- <br/>
- <div style="height:25px; font-size:12px; color:#617d80; list-style:22px;">
- <!--{if emptyempty($_TPL[hidden_time])}-->
- <span class="gray"><!--{date('m-d H:i',$r[dateline],1)}--></span>
- <!--{/if}-->
- <span style="margin-left:15px; color:#124981;">
- (<a href="javascript:;" onclick="dowxwcomment_get('dowxwcomment_$r[newsid]', 1);" id="dowxw_a_op_$r[newsid]">回复</a>)
- (<a href="cp.php?ac=share&type=blog&id=$blog[blogid]" id="a_share" onclick="ajaxmenu(event, this.id, 1)" class="a_share">分享</a>) //开源软件:Vevb.com
- </span></div>
- <div id="dowxwcomment_$r[newsid]" style="display:none;"></div>
- </td></tr></table>
- <!--{/loop}-->
- <!--{else}-->
- <span class="gray">好友还没有发布微新闻!</span>
- <!--{/if}-->
- </div>
相应的a.php页面:
- //分页
- $perpage =5; //;$_SCONFIG['feedmaxnum']<50?50:$_SCONFIG['feedmaxnum'];
- $start = 0;
- if($_GET['pages']>1)
- {
- $perpage=$perpage*$_GET['pages'];
- }
- $perpage = mob_perpage($perpage);
- $query= $_SGLOBAL['db']->query("SELECT a.newsid,a.username,a.uid,a.dateline,b.message FROM ".tname('m_news')." as a left join ".tname('m_newsfield')." as b on a.newsid=b.newsid where a.uid=".$space[uid]." order by dateline desc LIMIT $start,$perpage");
- $count = $filtercount = 0;
- $wxwlist=array();
- while ($value=$_SGLOBAL['db']->fetch_array($query)) {
- $wxwlist[] = $value;
- $count++;
- };
调用的JS代码,也同样用个性签名的来做修改:
- <script type="text/javascript">
- function statusFace() {
- if($('mood_message_wxw').value == '你可以在这里发布你相关的所见所闻,分享给大家!'){
- $('mood_message_wxw').value = '';
- }
- $('mood_statusinput_wxw').style.zIndex = '20000';
- $('mood_statusinput_wxw').className = 'statusinput2_wxw';
- var div = $('mood_face_bg');
- if(div) {
- div.parentNode.removeChild(div);
- }
- div = document.createElement('div');
- div.id = 'mood_face_bg';
- div.style.position = 'absolute';
- div.style.left = div.style.top = '0px';
- div.style.width = '100%';
- div.style.height = document.body.scrollHeight + 'px';
- div.style.backgroundColor = '#000';
- div.style.zIndex = 10000;
- div.style.display = 'none';
- div.style.filter = 'alpha(opacity=0)';
- div.style.opacity = 0;
- div.onclick = function() {
- hiddenstatus();
- }
- $('append_parent').appendChild(div);
- if($('mood_message_wxw_menu') != null) {
- $('mood_message_wxw_menu').style.display = '';
- $('mood_add_wxw').style.display = '';
- } else {
- var faceDiv = document.createElement("div");
- faceDiv.id = 'mood_message_wxw_menu';
- faceDiv.className = 'facebox';
- faceDiv.style.position = 'absolute';
- var faceul = document.createElement("ul");
- for(i=1; i<31; i++) {
- getStatusFace(i, faceul);
- }
- faceDiv.appendChild(faceul);
- $('append_parent').appendChild(faceDiv);
- }
- //定位菜单
- setMenuPosition('mood_message_wxw', 0);
- div.style.display = '';
- }
- function hiddenstatus() {
- $('mood_message_wxw_menu').style.display = 'none';
- $('mood_face_bg').style.display = 'none';
- $('mood_statusinput_wxw').className = 'statusinput_wxw';
- if($('mood_message_wxw').value == ''){
- $('mood_message_wxw').value = '你可以在这里发布你相关的所见所闻,分享给大家!';
- }
- $('mood_statusinput_wxw').style.zIndex = '1';
- }
- function getStatusFace(i, faceul) {
- var faceli = document.createElement("li");
- faceli.innerHTML = '<img src="image/face/'+i+'.gif" style="cursor:pointer; position:relative;" />';
- faceli.getElementsByTagName('img').item(0).onclick = function(){var faceText = '[em:'+i+':]'; if($('mood_message_wxw') != null) { insertContent('mood_message_wxw', faceText); }};
- faceul.appendChild(faceli);
- }
- function reloadMood(showid, result) {
- var x = new Ajax();
- x.get('cp.php?ac=mnews&op=getwxw', function(s){
- $('mood_mystatus_wxw').innerHTML = s;
- });
- //提示获得积分
- showreward();
- hiddenstatus();
- }
- </script>
以上就完成了发布框的与微新闻信息的显示,接下来看如果发布微新闻,当点击发布按钮时:
- <input type="button" id="mood_add_wxw" name="add_wxw" value="发布" class="submit" style="display:block;" onclick="ajaxpost('mood_addwxwform', 'reloadMood');$('mood_message_wxw').value='';" />
表单提交到mnews.php:
- <form method="post" action="cp.php?ac=mnews" id="mood_addwxwform">
- mnews.php代码部分:
- [html] view plaincopyprint?
- if(submitcheck('addsubmit')) {
- if(emptyempty($mnews['newsid']))
- {
- $mnews = array();
- }
- else
- {
- if(!checkperm('allowmblog'))
- {
- ckspacelog();
- showmessage('no_authority_to_add_log');
- }
- }
- include_once(S_ROOT.'./source/function_mnews.php');
- //入库
- if($newmnews = mnews_post($_POST, $mnews)) {
- //开源软件:Vevb.com
- $aa="1";
- }
- }
至此发布功能完成,接下来是回复,回复延用动态信息的回复框:
- <span id="dowxwcomment_form_{$newsid}_{$id}">
- <form id="dowxwcommform_{$newsid}_{$id}" method="post" action="cp.php?ac=comment" style="padding-left:10px;">
- <a href="#" id="do_face_{$newsid}_{$id}" title="插入表情" onclick="showFace(this.id, 'do_message_{$newsid}_{$id}');return false;"><img src="image/facelist.gif" align="absmiddle" /></a>
- <input type="text" id="do_message_{$newsid}_{$id}" name="message" size="35" class="t_input" onkeydown="return ctrlEnter(event, 'dowxwcommform_btn_{$newsid}_{$id}', 1);">
- <input type="hidden" name="commentsubmit" value="true" />
- <input type="hidden" name="idtype" value="newsid">
- <input type="hidden" name="id" value="{$newsid}">
- <input type="button" name="do_button" class="submit" id="dowxwcommform_btn_{$newsid}_{$id}" onclick="ajaxpost('dowxwcommform_{$newsid}_{$id}', 'dowxwcomment_get', 1)" value="回复">
- <button type="button" name="btncancel" class="button" onclick="dowxwcomment_form_close($newsid, $id);">取消</button>
- <input type="hidden" name="formhash" value="<!--{eval echo formhash();}-->" />
- </form>
- <div id="__dowxwcommform_{$newsid}_{$id}"></div>
- </span>
以上表单,提交到:
- action="cp.php?ac=comment",完成入库,统计,权限判断等操作后返回请求页面
- if($_POST['idtype']=='newsid')
- {
- $url='cp.php?ac=mnews&op=getcomment';
- }
- showmessage($msg, $url, 0, $magvalues);
回复功能完成.
新闻热点
疑难解答