您的位置:首页 > 其它

修改栏目名称,修改页获取id的父栏目

2017-02-11 22:11 162 查看
public function cateedit(){
$catModel = D('Cat');
if(IS_POST){
$cat_id = I('cat_id');
if($catModel->where('cat_id=' . $cat_id)->save($_POST)){
$this->redirect('Admin/cat/catelist');exit;
}

}

$this->assign('gettree',$catModel->gettree());//获取全部数据数据传给view模板
$this->assign('catinfo',$catModel->find(I('cat_id')));//获取$catModel->find(I('cat_id')数据传给view模板
$this->display();//

}

<?php
namespace Admin\Model;
use Think\Model;

class CatModel extends Model{
public function gettree(){
return $this->select();
}

}

点击编辑的时候,首先判断有没有post过来数据?没有传过来数据说明点击编辑的时候进入的还没有更新提交

$this->assign('gettree',$catModel->gettree());//获取全部数据数据传给view模板
$this->assign('catinfo',$catModel->find(I('cat_id')));//获取$catModel->find(I('cat_id')数据传给view模板
$this->display();//获取cat栏目下的所有信息    传送给view模板
然后根据id获取修改前的的内容  传值给view模板

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>ECSHOP 管理中心 - 添加分类 </title>
<meta name="robots" content="noindex, nofollow">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="__PUBLIC__/Admin/css/general.css" rel="stylesheet" type="text/css" />
<link href="__PUBLIC__/Admin/css/main.css" rel="stylesheet" type="text/css" />
</head>
<body>

<h1>
<span class="action-span"><a href="catelist.html">商品分类</a></span>
<span class="action-span1"><a href="#">ECSHOP 管理中心</a> </span><span id="search_id" class="action-span1"> - 添加分类 </span>
<div style="clear:both"></div>
</h1>

<div class="main-div">
<form action="{:U('admin/cat/cateedit')}" method="post" name="theForm" enctype="multipart/form-data">
<table width="100%" id="general-table">
<tr>
<td class="label">分类名称:</td>
<td>
<input type='text' name='cat_name' maxlength="20" value='{$catinfo.cat_name}' size='27' /> <font color="red">*</font>
</td>
</tr>
<tr>
<td class="label">上级分类:</td>
<td>
<select name="parent_id">
<!-- <option value="0">leixing</option> -->
<foreach name="gettree" item="c">
<option value="{$c.cat_id}" {$c['cat_id']==$catinfo['parent_id']?'selected':''} >{$c.cat_name}</option>
</foreach>

<!---
<option value="3">  GSM手机</option>
<option value="4">  3G手机</option>
<option value="5">  双模手机</option>
<option value="6">手机配件</option>
<option value="7">  充电器</option>
<option value="8">  耳机</option>
<option value="9">  电池</option>
<option value="11">  读卡器和内存卡</option>
<option value="12">充值卡</option>
<option value="13">  小灵通/固话充值卡</option>
<option value="14">  移动手机充值卡</option>
<option value="15">  联通手机充值卡</option> -->
</select>
</td>
</tr>

<tr>
<td class="label">分类描述:</td>
<td>
<textarea name='intro' rows="6" cols="48">{$catinfo.intro}</textarea>
</td>
</tr>
</table>
<div class="button-div">
<input type="submit" value=" 确定 " />
<input type="reset" value=" 重置 " />
</div>
<!-- <input type="hidden" name="act" value="insert" />
<input type="hidden" name="old_cat_name" value="" />-->
<input type="hidden" name="cat_id" value="{$catinfo.cat_id}" />
</form>
</div>

<div id="footer">
共执行 3 个查询,用时 0.021687 秒,Gzip 已禁用,内存占用 2.081 MB<br />
版权所有 © 2005-2010 上海商派网络科技有限公司,并保留所有权利。</div>

</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: