首先列出当前用户的所有产品记录 编辑index方法: ~~~ public function index(){ } ~~~ 获取当前用户: ~~~ $activeuser = UserModel::where('status',1)->find(); $this->assign('activeuser', $activeuser['username']); ~~~ 产品列表: ~~~ $listcount = 0; $list = TplModel::where('uid',$activeuser['uid'])->order('tid', 'desc')->paginate(10); $listcount = TplModel::where('uid',$activeuser['uid'])->count(); $this->assign('listcount', $listcount); $this->assign('list', $list); return $this->fetch(); ~~~ 模板文件: /apps/index/view/template/index.html ~~~ {layout name="layout" /} <div class="container"> <div id="templatelist" class="grid"> {load href="__PUBLIC__/js/template_moderate.js" /} <div class="actions"> <ul> <li class="action"> <button type="button" onclick="location.href='http://127.0.0.1/tp5/public/index.php/index/template/add/';return false;" name="topicsubmit" id="fastpostsubmit" value="topicsubmit" tabindex="21" class="pn pnc btn btn-green"><strong>录入模板</strong></button> </li> </ul> </div> <div class="sorting"> <div class="ui8-select"> <span class="active-option">当前账户:<em>{$activeuser}</em> 共<em>{$listcount}</em>条记录</span> </div> </div> <form method="post" autocomplete="off" name="moderate" id="moderate" action="http://127.0.0.1/tp5/public/index.php/index/template/"> <table class="listbox" cellpadding="1" cellspacing="0"> <tbody> <tr class="ttr"> <td class="chk">选择</td> <td class="tname">模板名</td> <td class="nick">程序</td> <td class="nick">美工</td> <td class="nick">其他</td> <td class="nick">其他</td> <td class="type">状态</td> </tr> </tbody> {volist name="list" id="tpl" } <tbody id=""> <tr class="{if condition="$mod neq 1"}tr1{else /}tr2{/if}"> <td><input onclick="tmodclick(this)" type="checkbox" name="moderate[]" value="{$tpl.tid}"></td> <td><cite style="color:{$tpl.highlight_color};">{$tpl.tname}</cite></td> <td><cite>{$tpl.pnick_text}<em>{$tpl.prate_text}</em></cite></td> <td><cite>{$tpl.dnick_text}<em>{$tpl.drate_text}</em></cite></td> <td><cite>{$tpl.onick1_text}<em>{$tpl.orate1_text}</em></cite></td> <td><cite>{$tpl.onick2_text}<em>{$tpl.orate2_text}</em></cite></td> <td><cite>{$tpl.ttype_text}</cite></td> </tr> </tbody> {/volist} </table> {load href="__PUBLIC__/css/moderator.css" /} <div id="mdly" style="display: none;"> <table cellpadding="0" cellspacing="0"> <tbody> <tr> <td class="t_l"></td> <td class="t_c"></td> <td class="t_r"></td> </tr> <tr> <td class="m_l"></td> <td class="m_c"> <div class="popcon"> <input type="hidden" name="optgroup"> <input type="hidden" name="operation"> <a class="cp" href="javascript:;" title="最小化" onclick="$('mdly').className='cpd'">最小化</a> <label><input type="checkbox" name="chkall" class="pc" onclick="if(!($('mdct').innerHTML = modclickcount = checkall(this.form, 'moderate'))) {$('mdly').style.display = 'none';}">全选</label> <h6><span>选中</span><strong onclick="$('mdly').className='';" onmouseover="this.title='最大化'" id="mdct" title="最大化">2</strong><span>条记录: </span></h6> <p> <table class="formbox" cellpadding="10" cellspacing="0"> <tbody> <tr> <td><button type="button" onclick="tmodtemplate(2, 'programmer');return false;" tabindex="100" class="pn pnc btn btn-small btn-green"><strong>指定程序</strong></button></td> <td><input type="text" id="tp" name="programmername" class="px" value="" tabindex="1" style="width: 70px" /></td> <td><input type="text" id="tpr" name="programmerrate" class="px" value="" tabindex="2" style="width: 70px" /></td> </tr> <tr> <td><button type="button" onclick="tmodtemplate(2, 'designer');return false;" tabindex="101" class="pn pnc btn btn-small btn-green"><strong>指定美工</strong></button></td> <td><input type="text" id="td" name="designername" class="px" value="" tabindex="3" style="width: 70px" /></td> <td><input type="text" id="tdr" name="designerrate" class="px" value="" tabindex="4" style="width: 70px" /></td> </tr> <tr> <td><button type="button" onclick="tmodtemplate(2, 'other1');return false;" tabindex="102" class="pn pnc btn btn-small btn-green"><strong>第三方一</strong></button></td> <td><input type="text" id="to1" name="other1name" class="px" value="" tabindex="5" style="width: 70px" /></td> <td><input type="text" id="to1r" name="other1rate" class="px" value="" tabindex="6" style="width: 70px" /></td> </tr> <tr> <td><button type="button" onclick="tmodtemplate(2, 'other2');return false;" tabindex="103" class="pn pnc btn btn-small btn-green"><strong>第三方二</strong></button></td> <td><input type="text" id="to2" name="other2name" class="px" value="" tabindex="7" style="width: 70px" /></td> <td><input type="text" id="to2r" name="other2rate" class="px" value="" tabindex="8" style="width: 70px" /></td> </tr> <tr> <td> <button type="button" onclick="tmodtemplate(2, 'highlight');return false;" tabindex="104" class="pn pnc btn btn-small btn-green"><strong>高亮</strong></button> </td> <td><a href="javascript:;" id="highlight_color_ctrl" onclick="showHighLightColor('highlight_color')" class="pn colorwd" /></a></td> <td><input type="hidden" id="highlight_color" name="highlight_color" value="" /></td> <td></td> <td></td> </tr> <tr> <td colspan="2"> <button type="button" onclick="tmodtemplate(2, 'type');return false;" tabindex="105" class="pn pnc btn btn-small btn-green"><strong>状态</strong></button> <button type="button" onclick="tmodtemplate(3, 'delete');return false;" name="delsubmit" id="delsubmit" value="delsubmit" tabindex="105" class="pn pnc btn btn-small btn-red"><strong>删除</strong></button> </td> <td>名称 + 分成 示例:0.50</td> <td></td> <td></td> </tr> </tbody> </table> </p> </div> </td> <td class="m_r"></td> </tr> <tr> <td class="b_l"></td> <td class="b_c"></td> <td class="b_r"></td> </tr> </tbody> </table> </div> </form> <div class="pgbox"> {$list->render()} </div> </div> </div> <script type="text/javascript" reload="1"> function showHighLightColor(hlid) { var showid = hlid + '_ctrl'; if(!$(showid + '_menu')) { var str = ''; var coloroptions = {'0' : '#fff', '1' : '#EE1B2E', '2' : '#EE5023', '3' : '#996600', '4' : '#3C9D40', '5' : '#2897C5', '6' : '#2B65B7', '7' : '#8F2A90', '8' : '#EC1282'}; var menu = document.createElement('div'); menu.id = showid + '_menu'; menu.className = 'cmen'; menu.style.display = 'none'; for(var i in coloroptions) { str += '<a href="javascript:;" onclick="$(\'' + hlid + '\').value=' + i + ';$(\'' + showid + '\').style.backgroundColor=\'' + coloroptions[i] + '\';hideMenu(\'' + menu.id + '\')" style="background:' + coloroptions[i] + ';color:' + coloroptions[i] + ';">' + coloroptions[i] + '</a>'; } menu.innerHTML = str; $('append_parent').appendChild(menu); } showMenu({'ctrlid':hlid + '_ctrl','evt':'click','showid':showid}); } </script> ~~~ 打开浏览器 http://127.0.0.1/tp5/public/index.php/index/template/ 页面输出类似 ![](https://box.kancloud.cn/2016-07-28_57997a6b080cf.png)