DEDECMS如何限制某个字段只能会员才能浏览
/member/indexphp 搜索 / 最新文档8条 /
在其上方增加
//统计文章总数量$count = $dsql->GetOne("select COUNT() AS dd FROM #@__archives where mid='"$cfg_ml->M_ID"'");
//统计文章总点击数
$counts = $dsql->GetOne("select sum(click) AS count_number FROM #@__archives where mid='"$cfg_ml->M_ID"'");
indexhtm 模版中调用 统计文章总数量
<php echo $count['dd'];>indexhtm 模版中调用 统计文章总点击数
<php echo $counts['count_number'];>织梦默认的模板不是有这个登陆的东西,你把代码复制过来,然后样式自己需要什么样修改就行了。
<form name="userlogin" action="{dede:globalcfg_memberurl/}/index_dophp" method="POST"><input type="hidden" name="fmdo" value="login" />
<input type="hidden" name="dopost" value="login" />
<input type="hidden" name="keeptime" value="604800" />
<div class="fb"><span>用户名:</span>
<input type="text" name="userid" size="20" class="ipt-txt" />
</div>
<div class="fb"><span>密码:</span>
<input type="password" name="pwd" size="20" class="ipt-txt" />
</div>
{dede:php}
if(preg_match("#2#", $safe_gdopen))
{
echo '
<div class="fb"><span>验证码:</span>
<input type="text" name="vdcode" size="8" class="ipt-txt" />
<img id="vdimgck" align="absmiddle" onClick="thissrc=thissrc+\'\'" style="cursor:pointer;margin-left:0px;text-transform:uppercase;" alt="看不清?点击更换" src="'$cfg_cmspath'/include/vdimgckphp"/></div>
';
}
{/dede:php}
<div class="submit">
<button type="submit" class="btn-1">登录</button>
<a href="{dede:globalcfg_memberurl/}/index_dophpfmdo=user&dopost=regnew" >注册帐号</a> <a href="{dede:globalcfg_memberurl/}/resetpasswordphp">忘记密码</a> </div>
</form>
我们可以用传递参数加SQL实现,具体方法如下: 1、在内容页head之间加上JS:
<script src="{dede:globalcfg_cmsurl/}/include/dedeajax2js" type="text/javascript" ></script>
<script language="javascript">
function CheckLogin_c(){
var taget_obj = documentgetElementById('_userlogin_c');
var req = documentgetElementById('hid')value;
myajax = new DedeAjax(taget_obj,false,false,'','','');
myajaxSendGet2("{dede:globalcfg_cmspath/}/member/ajax_loginsta_cphpval="+req);
DedeXHTTP = null;
}
</script> 2、在内容页需要会员限制才能查看的地方添加代码(会员登录前的样子):
<span id="_userlogin_c"><a href="/member/index_dophpfmdo=user&dopost=regnew">请注册后查看!</a></span>
<input type="hidden" value="{dede:fieldaid/}" id="hid" />
<script language="javascript" type="text/javascript">CheckLogin_c();</script>
这里获取文章ID的文本框一定要在js之前 3、在/member文件夹中新建一个文件:ajax_loginsta_cphp,添加如下代码(会员登录后的样子):
<php
require_once(dirname(__FILE__)"/configphp");
AjaxHead();
if($myurl == '')
{
exit('');
}
$uid = $cfg_ml->M_LoginID;!$cfg_ml->fields['face'] && $face = ($cfg_ml->fields['sex'] == '女') 'dfgirl' : 'dfboy';
$facepic = empty($face) $cfg_ml->fields['face'] : $GLOBALS['cfg_memberurl']'/templets/images/'$face'png';>
<php
$row = $dsql->GetOne(" Select From `js_addoninfos` where `aid`=$val ");
>
<php echo $row['tel']; > 经本人测试,没有任何问题!参考网站: http://wwwjisuxcom/science/dedecms/2011/221html
0条评论