您现在的位置是:首页 > 教程 > 帝国CMS教程帝国CMS教程
帝国CMS二次开发怎么设置会员随机头像
谢协湃2023-05-12 23:37:13帝国CMS教程已有人查阅
导读帝国cms二次开发后的效果,帝国CMS随机会员头像功能开发步骤,首先把会员的“userpic”字段设置为文本类型,主要用来存头像路径。然后在新建一个“userpic2”字段
帝国cms二次开发后的效果,帝国CMS随机会员头像功能开发步骤
1、首先把会员的“userpic”字段设置为文本类型,主要用来存头像路径。然后在新建一个“userpic2”字段,主要用来上传头像。
2、随机头像图片代码
<table width="100%">
<tr>
<td valign="top">随机图像:</td>
<td bgcolor='ffffff'>
<img src='/e/template/Style/img/1.jpg' id='img2' width="180" height="180" />
</td>
</tr>
<tr>
<td colspan="2" height="20"></td>
</tr>
<tr>
<td colspan="2"><a class="changeImg" href="javascript:void(0)" onclick="ChangeFace()">换一张</a>
</td>
</tr>
<tr>
<td colspan="2" height="20"></td>
</tr>
<tr>
<td colspan="2" align="center">
<button class="editPassword-submit" type="submit" id="faceSubmit">使用头像</button>
</td></tr>
</table>
<script type="text/javascript">
function ChangeFace() {
//x上限,y下限
var x = 10;
var y = 1;
var rand = parseInt(Math.random() * (x - y + 1) + y);
var face = '/e/template/Style/img/' + rand + '.jpg';
$("#img2").attr('src', face);
$("input[name='userpic']").attr('value', face);
}
</script>
3、userpic字段代码
<input name="userpic" type="text" id="userpic" value="<?=$ecmsfirstpost==1?"":ehtmlspecialchars(stripSlashes($addr[userpic]))?>" size="" style="display:none">
<?=empty($addr[userpic])?"":"<img src='".ehtmlspecialchars(stripSlashes($addr[userpic]))."' border=0 id=img2>"?><br>
4、userpic2字段代码
<input type="file" name="userpic2file" size="45">
<input name="userpic2" type="text" id="userpic2" value="<?=$ecmsfirstpost==1?"":ehtmlspecialchars(stripSlashes($addr[userpic2]))?>" size="" style="display:none">
5、给表单上传图片提交按钮设置一个ID
<input type='submit' name='Submit' value='上传头像' onclick="bt();">
让他在提交前,把上传的userpic2字段内容赋值到userpic字段里面。
function bt(){
var txt = $("input[name='userpic2']").val();
$("input[name='userpic']").attr('value',txt);
}
这样就可以了,点击左边的“上传图片”按钮会把userpic2的内容给userpic,点击右边的“使用头像”按钮,也会把随机生成的头像地址赋值给userpic。个人觉得挺麻烦的,主要是不想改程序,就用这种“障眼法”来完成。
本文标签:
很赞哦! ()
相关文章
随机图文
-
帝国CMS报错Warning: Cannot modify header information怎么办
今天偶然进入帝国CMS网站后台发现出现了:Warning:Cannot modify header information - headers already sent by -
帝国CMS怎么更改消息提醒
帝国CMS更改消息提醒的弹窗提示教程。查找“您有新消息”源代码找到其所在的位置。例如:e/member/login/loginjs.php文件 -
帝国CMS首页怎么调用会员数/留言数/评论数的代码方法
其实就是用SQL语句的count来统计数据表里面的信息数,具体代码如下:(直接模板里用PHP输出即可) -
帝国CMS自定义列表制作专题列表的方法
帝国CMS自定义列表制作专题列表的方法,因为在列表模板中不支持“自定义列表的字段”,所以用“自定义列表的字段”as “列表模板支持的字段”变量名。
留言与评论 (共有 条评论) |