我在织梦dedecms 某模型里面增加了一个电话号码的字段tel,希望前台只让具有高级会员权限并且登录的用户才会显示,未登录时显示“请注册后才能显示”。这里用传递参数加SQL实现,具体方法如下: 1、在内容页head之间加上JS: <script src="{dede:global.cfg_cmsurl/}/include/dedeajax2.js" type="text/javascript" ></script> <script language="javascript"> function CheckLogin_c(){ var taget_obj = document.getElementById('_userlogin_c'); var req = document.getElementById('hid').value; myajax = new DedeAjax(taget_obj,false,false,'','',''); myajax.SendGet2("{dede:global.cfg_cmspath/}/member/ajax_loginsta_c.php?val="+req); DedeXHTTP = null; } </script> 2、在内容页需要会员限制才能查看的地方添加代码(会员登录前的样子): <span id="_userlogin_c"><a href="/member/index_do.php?fmdo=user&dopost=regnew">请注册后查看!</a></span> <input type="hidden" value="{dede:field.aid/}" id="hid" /> <script language="javascript" type="text/javascript">CheckLogin_c();</script> 这里获取文章ID的文本框一定要在js之前 3、在/member文件夹中新建一个文件:ajax_loginsta_c.php,添加如下代码(会员登录后的样子): (责任编辑:好模板)<?php require_once(dirname(__FILE__)."/config.php"); 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']; ?> |