注意:此方法也适用与其他字段,做好自己的设置即可

1、在<head>中加入


01 <script src="{dede:global.cfg_cmsurl/}/include/dedeajax2.js" type="text/javascript" ></script>
02 <script language="javascript">
03 function CheckLogin_c(){
04 var taget_obj = document.getElementById('_userlogin_c'); 
05  var req = document.getElementById('hid').value;
06  myajax = new DedeAjax(taget_obj,false,fal  se,'','','');
07  myajax.SendGet2("{dede:global.cfg_cmspath/}/member/ajax_loginsta_c.php?val="+req);
08  DedeXHTTP = null;
09 }
10 </script>

2、在模板中

1 <span id="_userlogin_c">
2 购买链接(未登录时候显示):{dede:field.url1/}<br />
3 市场价格(未登录时候显示):{dede:field.jiage1/}<br />
4 </span>
5 <input type="hidden" value="{dede:field.aid/}" id="hid" />
6 <script language="javascript" type="text/javascript">CheckLogin_c();</script>

3、在\member新建一个文件ajax_loginsta_c.php

01 <?php
02
09 require_once(dirname(__FILE__)."/config.php");
10 AjaxHead();
11 if($myurl == '') exit('');
12  
13 $uid  = $cfg_ml->M_LoginID;
14  
15 !$cfg_ml->fields['face'] && $face = ($cfg_ml->fields['sex'] == '女')? 'dfgirl' : 'dfboy';
16 $facepic = empty($face)? $cfg_ml->fields['face'] : $GLOBALS['cfg_memberurl'].'/templets/images/'.$face.'.png';
17 ?>
18  
19 <?php
20 $rank=$cfg_ml->M_Rank;
21 $row = $dsql->GetOne(" Select * From `dede_addon19` where `aid`=$val ");
22 ?>
23  
24  
25 购买链接(已登录):<?php  echo $row['url2'];?><br />
26 本店价格:<?php  echo $row['jiage2'];?><br />

THE END

非特殊说明,本博所有文章均为博主原创

如若转载,请注明出处:https://www.htmlbk.com/dedecms/528.html