浅生 发表于 2021-5-13 16:01:54

discuz模板修改常用代码大全

DZ插件网discuz模板修改终极秘籍!搜集常用的修改代码和方法技巧!持续更新!


1,在html模板里面进行计算的代码:计算附件购买不足的时候,还差多少积分(以第二项积分来计算) <!--{echo $attach-getuserprofile('extcredits2');}-->
2,在HTML模板里面输出对应项的积分:假设需要输出的积分为第二项<!--{eval echo getuserprofile('extcredits2');}-->3,模板文件中直接调用SQL指定内容<!--{eval echo DB::result_first("select username from pre_common_member where uid=1");}--><!--{eval echo DB::result_first("select bio from pre_common_member_profile where uid=1");}-->这是一个直接输出的值,示例中
username/bio :表示具体调用表中的项目
pre_common_member/pre_common_member_profile :表示具体调用的表名
uid=1" :表示具体调用表中的项目

浅生 发表于 2021-5-13 16:02:50

判断当前页面名称,比如判断当前是否位于帖子内容页的代码:<!--{if $_G['mod'] == 'viewthread'}-->执行位于内容页的代码<!--{/if}-->

Crystαl 发表于 2021-5-13 16:03:14


代码文件:
        .all{ width:100%; margin:0px auto 25px;background:#f0f0f0;padding-top: 20px;}.all i{font-style:normal;}.all a{text-decoration: blink;color: #4169E1;}.all a:hover{color:#ff0000;}.all ul{ padding-top:10px; margin-left:0px; zoom:1; overflow:hidden;padding-bottom:20px; }.all li{ float:left; width:205px; height:34px; margin-left:20px;display:inline;text-align:center; line-height:34px}.all li a{ font-size:15px; color:#ffffff;font-weight:bold; display:block ;background:#31b365;}.all li a:hover{ background:#31B365;    color: #F5F505}.all p{color: #000000;padding: 10px;width: 910px;margin-left: 20px;line-height:12px;font-size:17px;}.qqqun{background-color: #4CAF50;margin-left: 10px;border: none;color: white;text-align: center;font-size: 16px;-webkit-transition-duration: 0.4s;transition-duration: 0.4s;border-radius: 5px;box-shadow: 1px 1px 1px 1px #CCC;}.qqqun:hover{box-shadow: 1px 1px 1px 1px #4169e1;}
【DZ插件网资源下载指南】--默认解压密码:www.moqu8.com<font color="0000FF">   
1,如有异常请按 F5 刷新本页面!   【资源维权反馈】
2,首发及精品资源受到保护,扣除趣币!趣币可通过分享资源免费获得!懒人也可选择赞助充值!
不能解压怎么办?   免费赚趣币趣豆!   微信/支付宝赞助充值   下载不了怎么办?

.button a{color: #fff;text-decoration: none;};                                                               请点击此处下载            请先注册会员后在进行下载
            已注册会员,请先登录后下载
                           
                                 <em> 售价: 免费 搜索结果添加缩略图.rar488 Bytes                                     | 已下载: 1 次
                                  权限:普通用户    (已享有下载权限)                                                                        
         
                  <div class="tip tip_4 " id="attach_18972_menu" style="position: absolute; display: none" disautofocus="true"><div class="tip_c xs0">2017-6-6 22:13 上传
点击文件名下载附件

拾光 发表于 2021-5-13 16:04:04

输出当前时间{lang time_now}

discuz在HTML页面中使用PHP输出的方法:<!--{echo date(Y);}-->即加上注释符号即可!

浅生 发表于 2021-5-13 16:04:57

discuz在页面中使用缓存判断,实现输出可控制数量的内容:下面的代码实现只输出一次【需要输出的内容】的功能!

<!--{if $_G['my_var']!=1}-->需要输出的内容      <!--{/if}-->      <!--{eval $_G['my_var'] = 1;}-->

拾光 发表于 2021-5-13 16:05:57

discuz分类信息具体项目调用代码及教程:点击这里

TyCoding 发表于 2021-5-13 16:06:38

discuz调用数据库字段的方法<?phpdefine('APPTYPEID', 5);//必须的,你懂的define('CURSCRIPT', 'userapp');//必须的,你懂的require_once './source/class/class_core.php';//必须的,你懂的$discuz = & discuz_core::instance();//必须的,你懂的$discuz->cachelist = $cachelist;//必须的,你懂的$discuz->init();//必须的,你懂的 echo"cur userid:".$_G['uid']."</br>";//获到当前用户IDecho"cur username:".$_G['username']."</br>";//如上,你懂的$curuserid = $_G['uid'];//获到当前用户ID//使用数据库查询,调用discuz的数据库查询方法$cususerinfo = DB::fetch_first("SELECT * FROM ".DB::table('common_member')." WHERE uid='$curuserid'");//查出当前用户的EMIALecho "<br/>".$cususerinfo['email'];//要查其它的信息,进数据库会员表(不进就网上找个表介绍的看)先查出字段名,把emal换了就行了//查出所有用户,以注册日期排序$query = DB::query("SELECT * FROM ".DB::table('common_member')." order by regdate" );echo "<br/>" ;//换一行先//开始输出while($row = DB::fetch($query)) {echo$row["uid"]."" .$row["username"]."".$row["email"]."<br/>";} ?>

TyCoding 发表于 2021-5-13 16:07:33

为部分模板回帖增加用户组显示:<div style="margin-top:5px;margin-left: 10%;"><a href="home.php?mod=spacecp&ac=usergroup&gid=$post" target="_blank">{$post}</a>                                                </div>

拾光 发表于 2021-5-13 16:08:09

在html页面执行循环输出控制的方法,如下,利用注释标签使用i变量,输出三次后停止循环<!--{if $i<3}-->                                                                                        <!--{/if}-->                                                                              <!--{eval ++$i;}-->

TyCoding 发表于 2021-5-13 16:08:50

Discuz积分更新SQL语句:/** * 添加积分 * @param Integer $uids: 用户uid或者uid数组 * @param String $dataarr: 积分操作数组 * @param Boolean $checkgroup: 是否检查用户组 true or false * @param String $operation: 操作类型 * @param Integer $relatedid: * @param String $ruletxt: 积分规则文本 * @param String $customtitle: 自定义积分记录标题 * @param String $custommemo: 自定义积分记录说明 */      function updatemembercount($uids, $dataarr = array(), $checkgroup = true, $operation = '', $relatedid = 0, $ruletxt = '', $customtitle = '', $custommemo = '') {      if(!empty($uids) && (is_array($dataarr) && $dataarr)) {          require_once libfile('function/credit');          return _updatemembercount($uids, $dataarr, $checkgroup, $operation, $relatedid, $ruletxt, $customtitle, $custommemo);      }      return true;}调用方法:updatemembercount($_G['uid'], array(1=>10),true,'',123,'抽奖奖励','抽奖奖励','抽奖奖励');操作说明:给$_G['uid']用户添加积分extcredits1,数额10


$relatedid积分操作类型:
操作名字
关联ID
说明
ACCforum_activity.tid参与活动扣除积分AFDcommon_member.uid购买积分即积分赞助充值AGCcommon_magic.mid获得红包BACforum_attachment.aid购买附件支出积分BGCcommon_magic.mid埋下红包BMCcommon_magic.mid道具购买消耗积分BTCforum_thread.tid购买主题支出积分CDC1卡密赞助充值CECcommon_member.uid积分兑换ECUcommon_member.uid通过ucenter兑换积分MRCcommon_magic.mid道具随机获取积分PRCforum_post.pid帖子被评分所得积分RACforum_thread.tid最佳答案获取悬赏积分RCAforum_thread.tid回帖中奖RCBforum_thread.tid返还回帖奖励积分RCTforum_thread.tid回帖奖励积分RCVcommon_member.uid积分转账接收RGCcommon_magic.mid回收红包RKCcommon_member.uid竞价排名RPCcommon_report.id举报功能中的奖惩RSCforum_thread.tid评分帖子扣除自己的积分RTCforum_thread.tid发表悬赏主题扣除积分SACforum_attachment.aid出售附件获得积分STCforum_thread.tid出售主题获得积分TFRcommon_member.uid积分转账转出TRCcommon_task.taskid任务奖励积分UGPcommon_usergroup.groupid购买扩展用户组支出积分
页: [1]
查看完整版本: discuz模板修改常用代码大全

创宇盾启航版免费网站防御网站加速服务