DEDECMS如何限制某个字段只能会员才能浏览
<tr>
{dede:arclist
addfields='sjdz,yysj'
channelid='1'
row='10'
orderby='sendate'}
<td>商家地址:[field:sjdz/]</td>
<td>营业时间:[field:yysj/]</td>
{/dede:arclist}
</tr>
有些参数是我随意加上去的,关键是addfields和channelid,addfields里面是你的自定义字段,channelid如果是普通文章就是1,其他后台有,根据需要改。
第一步:打开"/include/commonfuncphp",该文件56版本默认存在,55的不存在自己建一个。
然后在该文件中加入一个函数,代码如下:
function pasterTempletDiy($path)
{
require_once(DEDEINC"/arcpartviewclassphp");
global $cfg_basedir,$cfg_templets_dir;
$tmpfile = $cfg_basedir$cfg_templets_dir"/"$path;//模版文件的路径
$dtp = new PartView();
$dtp->SetTemplet($tmpfile);
$dtp->Display();
}
在模板页用以下代码替换原因的调用头部代码
<php pasterTempletDiy("default/headhtm");>
我们可以用传递参数加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
修改dede/member_mainphp中的分页数,
$dlist->pageSize = 20; //修改此处的pagesize为你需要显示的数量<php/
附件管理
@version $Id: media_mainphp 1 11:17 2010年7月19日Z tianya $
@package DedeCMSAdministrator
@copyright Copyright (c) 2007 - 2010, DesDev, Inc
@license http://helpdedecmscom/usersguide/licensehtml
@link http://wwwdedecmscom
/
require_once(dirname(__FILE__)"/configphp");
require_once(DEDEINC"/datalistcpclassphp");
require_once(DEDEINC"/commonfuncphp");
setcookie("ENV_GOBACK_URL",$dedeNowurl,time()+3600,"/");
if(empty($dopost)) $dopost = '';
//文件式管理器
if($dopost=='filemanager')
{
if(file_exists('/file_manage_mainphp'))
{
header("location:file_manage_mainphpactivepath=$cfg_medias_dir");
}
else
{
ShowMsg("找不到文件管理器,可能已经卸载!","-1");
}
exit();
}
//数据库管理
// ------------------------------------------------------------------------
if(empty($keyword)) $keyword = "";
$addsql = " WHERE (utitle LIKE '%$keyword%' OR uurl LIKE '%$keyword%') ";
if(empty($membertype))
{
$membertype = 0;
}
if($membertype==1)
{
$addsql = " AND umid>0 ";
}
else if($membertype==2)
{
$addsql = " AND umid>0 ";
}
if(empty($mediatype))
{
$mediatype = 0;
}
if($mediatype>1)
{
$addsql = " AND umediatype='$membertype' ";
}
$sql = "SELECT uaid,utitle,uurl,umediatype,ufilesize,umid,uuptime
,auserid AS adminname,muserid AS membername
FROM #@__uploads u
LEFT JOIN #@__admin a ON aid = umid
LEFT JOIN #@__member m ON mmid = umid
$addsql ORDER BY uaid DESC";
$dlist = new DataListCP();
$dlist->pageSize = 20; //修改此处的pagesize为你需要显示的数量
$dlist->SetParameter("mediatype",$mediatype);
$dlist->SetParameter("keyword",$keyword);
$dlist->SetParameter("membertype",$membertype);
$dlist->SetTemplate(DEDEADMIN"/templets/media_mainhtm");
$dlist->SetSource($sql);
$dlist->Display();
function MediaType($tid,$nurl)
{
if($tid==1)
{
return "<a href=\"javascript:;\" onClick=\"ChangeImage('$nurl');\"><img src='/include/dialog/img/picviewnonegif' name='picview' border='0' alt='预览'></a>";
}
else if($tid==2)
{
return "FLASH";
}
else if($tid==3)
{
return "视频/音频";
}
else
{
return "附件/其它";
}
}
function GetFileSize($fs)
{
$fs = $fs/1024;
return trim(sprintf("%101f",$fs)" K");
}
function UploadAdmin($adminid,$mid)
{
if($adminid!='') return $adminid;
else return $mid;
}
0条评论