基于ThinkPHP的开发笔记4-显示活动列表

1、后台获取数据列表
$this->badmintonList=M('activity')->where('typeCode="badminton"')->order('createTime desc')->limit(3)->select();
$this->swimmingList=M('activity')->where('typeCode="swimming"')->order('createTime desc')->limit(3)->select();
$this->billiardsList=M('activity')->where('typeCode="billiards"')->order('createTime desc')->limit(3)->select();
2、前台使用模板标签进行渲染 ,其中链接是生成方式有点小麻烦
<div id="left">
	<div class="info">
		<div class="hd">
			<h2>羽毛球
			</h2>
		</div>
		<ul>
			<foreach name="badmintonList" item="vo">
				<li class="info_r">
					<div class="title_l"><a href="{:U('Activity/view',array('id'=>$vo['id']))}">{$vo.title}</a></div>
					<ul class="detail_l">
						<li>开始时间:{$vo.startTime}</li>
						<li>结束时间:{$vo.endTime}</li>
						<li>活动地点:{$vo.address}</li>
						<li>活动详情:{$vo.detail}</li>
					</ul>
				</li>	
			</foreach>		
		</ul>
	</div>
	<div class="info">
		<div class="hd">
			<h2>游泳
			</h2>
		</div>
		<ul>
			<foreach name="swimmingList" item="vo">
				<li class="info_r">
					<div class="title_l"><a href='#'>{$vo.title}</a></div>
					<ul class="detail_l">
						<li>开始时间:{$vo.startTime}</li>
						<li>结束时间:{$vo.endTime}</li>
						<li>活动地点:{$vo.address}</li>
						<li>活动详情:{$vo.detail}</li>
					</ul>
				</li>	
			</foreach>
		</ul>
	</div>
	<div class="info">
		<div class="hd">
			<h2>桌球
			</h2>
		</div>
		<ul>
			<foreach name="billiardsList" item="vo">
				<li class="info_r">
					<div class="title_l"><a href='#'>{$vo.title}</a></div>
					<ul class="detail_l">
						<li>开始时间:{$vo.startTime}</li>
						<li>结束时间:{$vo.endTime}</li>
						<li>活动地点:{$vo.address}</li>
						<li>活动详情:{$vo.detail}</li>
					</ul>
				</li>	
			</foreach>		
		</ul>
	</div>
	
	<div class="info">
		<div class="hd">
			<h2>其他
			</h2>
		</div>
		<ul>
		</ul>
	</div>
</div>

你可能感兴趣的:(基于ThinkPHP的开发笔记4-显示活动列表)