destoon二次开发会员后台自定义单页风格模板功能

 DestoonCMS   高蒙   阅读(2147)   评论(0)   2016-01-27 17:13:37    destoon二次开发 destoon会员后台开发 destoon单页风格设置 


项目中在destoon会员后台新建会员单页风格自定义功能。这个功能是项目中需要新加的功能,涉及到其他的表模版表 ys_template和destoon_member表,ys_template不是destoon系统内置的表。这里记录方面以后查阅。

ys_template表的数据结构:

ID NO Columns Color Stlye
1  1  1       蓝色  清新
2  2  3       红色  古典
...

destoon_member表中加上:

zs_tplno字段

效果如下:

QQ截图20160127165604.jpg

 

模板文件(左边导航):/template/default/member/header.htm 

{if $_userid}  // 判断会员是否登录
<li class="ziji 3" id="template">
<a href="template.php" id="ccid" class="n">
<div style="width:74px; float: left; height: 1px;"></div>
<img class="dian" src="image/houtai/dian.png" />
<span>单页风格</span>
<div style=" clear: both;"></div>
</a>
<a href="template.php?action=view" class="m">查看</a>
<div style=" clear: both;"></div>
</li>
{/if}

 

新建模板文件:template.htm

主要代码如下:

<form action="/member/template.php" method="get">
    <input type="hidden" name="action" value="soso">
    <div class="tt">
        <label>列数</label>
        <select name="col">
            <option <?php if($_GET['col'] == '') echo "selected";?> value="">不限列数</option>
            <option value="1" <?php if($_GET['col'] == 1) echo "selected";?> >1列</option>
            <option value="2" <?php if($_GET['col'] == 2) echo "selected";?> >2列</option>
            <option value="3" <?php if($_GET['col'] == 3) echo "selected";?> >3列</option>
            <option value="4" <?php if($_GET['col'] == 4) echo "selected";?> >4列</option>
        </select>
        <label>色系</label>
        <select name="color">
            <option <?php if($_GET['color'] == '') echo "selected";?> value="">不限色系</option>
            <option <?php if($_GET['color'] == '蓝色') echo "selected";?> value="蓝色">蓝色</option>
            <option <?php if($_GET['color'] == '绿色') echo "selected";?> value="绿色">绿色</option>
            <option <?php if($_GET['color'] == '黄色') echo "selected";?> value="黄色">黄色</option>
            <option <?php if($_GET['color'] == '红色') echo "selected";?> value="红色">红色</option>
            <option <?php if($_GET['color'] == '橙色') echo "selected";?> value="橙色">橙色</option>
            <option <?php if($_GET['color'] == '紫色') echo "selected";?> value="紫色">紫色</option>n>
        </select>

        <label>风格</label>
        <select name="style">
            <option <?php if($_GET['style'] == '') echo "selected";?> value="">不限风格</option>
            <option <?php if($_GET['style'] == '古典') echo "selected";?> value="古典">古典</option>
            <option <?php if($_GET['style'] == '简约') echo "selected";?> value="简约">简约</option>
            <option <?php if($_GET['style'] == '清新') echo "selected";?> value="清新">清新</option>
            <option <?php if($_GET['style'] == '活泼') echo "selected";?> value="活泼">活泼</option>
            <option <?php if($_GET['style'] == '商务') echo "selected";?> value="商务">商务</option>
        </select>
        <input type="submit" value="查询"> <span style="color:#FF0000">为您找到相关模板<b>{if $counts['num']}{$counts['num']}{else}0{/if}</b>个。</span>
    </div>
</form>
<style>
    .g_template{width: 100%;overflow: hidden;}
    .g_template dl{ width: 220px; text-align: center;float: left;margin: 10px 0;}
    .g_template dt{ width: 220px; text-align: center}
    .g_template dt img{max-width: 200px;max-height: 150px}
    .g_template dd{ width: 220px; text-align: center; margin: 0;  line-height:30px;}
    .pages a:link, .pages a:visited, .pages a:active { padding: 5px 10px; display: inline-block; margin: 10px}
</style>

<div class="g_template">
    {if $lists}
    {loop $lists $v}
    <dl>
        <dt><img src="{if $v['NO']}http://localhost/P/{$v['NO']}/s.gif{else}/company/skin/companywindow/thumb.gif{/if}"></dt>
        <dd>参数:{$v['Columns']} / {$v['Color']} / {$v['Stlye']} &nbsp;|&nbsp;<a href="/member/template.php?action=itemid&id={$v['NO']}" class="t">启用</a></dd>
    </dl>
    {/loop}
    {else}
    <span style="color:#FF0000">提示信息:未找到相关模板</span>
    {/if}
</div>
<div class="pages">
    <a href="{$perv}">上一页</a>
    <a href="{$next}">下一页</a>
</div>

 

新建程序文件:/member/template.php

代码如下:

<?php 

require 'config.inc.php';
require '../common.inc.php';
require DT_ROOT.'/module/'.$module.'/template.inc.php';

?>

 

新建程序代码:/module/member/template.inc.php

代码如下:

<?php

/*
 * // 新加 20160127 单页模版选择功能
*/

defined('IN_DESTOON') or exit('Access Denied');
require DT_ROOT.'/module/'.$module.'/common.inc.php';
require DT_ROOT.'/include/post.func.php';
require MD_ROOT.'/style.class.php';
$action = $_GET['action'];

if($action == 'view'){
    // 显示会员的单页模版
    $c = $db->get_one("SELECT zs_tplno FROM {$DT_PRE}member WHERE userid=$_userid");
    $thumb = $c['zs_tplno'];
    if(!empty($thumb)){
        $thumb = "http://img.yaozs.com/P/".$thumb."/s.gif";
    }else{
        $thumb = $MODULE[4]['linkurl'].'image/nothumb.gif';
    }
}elseif($action == 'itemid'){
    // 处理选定的模板
    $sql = " update destoon_member set zs_tplno ='".$_GET['id']."' WHERE userid=$_userid";
    $db->query($sql);
    $msg = "模版修改成功";
    dmsg($msg, $forward);
    //header("location:/member/template.php?action=view");
}else{
    // 处理搜索的程序
    $pagesize = 20;
    if(!isset($page)) $page=1;
    $condition = " where 1=1 ";
    if($action == 'soso'){
        $condition  .= $_GET['col']?"  and Columns ='".$_GET['col']."'":" ";
        $condition  .= $_GET['color']?" and Color ='".$_GET['color']."'":' ';
        $condition  .= $_GET['style']?" and Stlye ='".$_GET['style']."'":" ";
    }

    $offset = ($page-1)*$pagesize;
    $counts = $db->get_one("SELECT count(id) num FROM  ys_template {$condition}");
    $items = ceil($counts['num']/20);
    $sql = " select * from  ys_template  ".$condition." order by id desc LIMIT {$offset},{$pagesize}" ;
    $res = $db->query($sql);
    $lists = array();
    while($r = $db->fetch_array($res)){
        $lists[] = $r;
    }
    if($page > $items){
        $perv = $items-1;
        $next = $items;
    }elseif($page <= 1){
        $perv = 1;
        $next = 2;
    }elseif($page < $items){
        $perv = $page-1;
        $next = $page+1;
    }elseif($page == $items){
        $perv = $items-1;
        $next = $items;
    }else{
        $perv = $page-1;
        $next = $page+1;
    }

    if($action == 'soso'){
        $condi = "";
        if($_GET['col']) $condi .= "&col={$_GET['col']}";
        if($_GET['color']) $condi .= "&color={$_GET['color']}";
        if($_GET['style']) $condi .= "&style={$_GET['style']}";
        $perv = "/member/template.php?action=soso&page={$perv}{$condi}";
        $next = "/member/template.php?action=soso&page={$next}{$condi}";
    }else{
        $perv = "/member/template.php?page={$perv}";
        $next = "/member/template.php?page={$next}";
    }
    $db->free_result($res);
}

include template('template', $module);

 




相关文章



我要评论


站长昵称:(*)

输入内容:


评论列表


高蒙

男,程序猿一枚

 

人生要是没有理想, 那跟一条咸鱼有什么分别。


关于我

  http://www.shuchengxian.com

高蒙个人博客是以PHP技术为主的程序员个人博客。博客主要发布php开发中遇到的问题以及解决办法,同时个人博客也分享网站模板素材,jquery插件等方面素材。


站点声明:相关侵权、举报、投诉及建议等,请发E-mail:936594075#qq.com(#替换成@)。

Copyright © 2018, www.shuchengxian.com, All rights reserved. 个人博客皖公网安备 34152302000022号 皖ICP备15015490号

关键词:个人博客,PHP博客,PHP博客程序,高蒙博客,高蒙个人博客,php程序员博客,程序员个人博客