<volist name="news" id="item">
<li ><i><img src="images2/icon6.png"></i><a href="{:U('Item/index',array('id'=>$item['id']))}">{$item.title}</a></li>
</volist> 如果把调用模板代码加在商品页面最下面,就没问题,也就是说加在上面就有这个问题,马上大神帮忙看下呗!<?php
class itemAction extends frontendAction {
public function _initialize() {
parent::_initialize();
//访问者控制
if (!$this->visitor->is_login && in_array(ACTION_NAME, array('share_item', 'fetch_item', 'publish_item', 'like', 'unlike', 'delete', 'comment'))) {
IS_AJAX && $this->ajaxReturn(0, L('login_please'));
$this->redirect('user/login');
}
}
/**
* 商品详细页
*/
public function index() {
$id = $this->_get('id', 'intval');
!$id && $this->_404();
$item_mod = M('item');
$item = $item_mod->field('id,title,intro,price,info,comments,add_time,goods_stock,buy_num,brand,size,color')->where(array('id' => $id, 'status' => 1))->find();
!$item && $this->_404();
/**
* ***品牌
*/
$brand=M('brandlist')->field('name')->find($item['brand']);
$item['brand']=$brand['name'];
//商品相册
$img_list = M('item_img')->field('url')->where(array('item_id' => $id))->order('ordid')->select();
//标签
$item['tag_list'] = unserialize($item['tag_cache']);
$this->assign('item', $item);
$this->assign('img_list', $img_list);
$this->assign('cmt_list', $cmt_list);
$wherenews=array('news'=>1);
$news=$this->getItem($wherenews);
$this->assign('news',$news);
$this->display();
}
public function getItem($where = array())
{
$where_init = array('status'=>'1');
$where =array_merge($where_init, $where);
return $item=M('item')->where($where)->select();
}
//获取商品信息
public function fetch_item() {
$url = $this->_get('url', 'trim');
$url == '' && $this->ajaxReturn(0, L('please_input') . L('correct_itemurl'));
$aid = $this->_get('aid', 'intval');
//获取商品信息
$itemcollect = new itemcollect();
!$itemcollect->url_parse($url) && $this->ajaxReturn(0, L('please_input') . L('correct_itemurl'));
if (!$info = $itemcollect->fetch()) {
$this->ajaxReturn(0, L('fetch_item_failed'));
}
$this->assign('item', $info['item']);
$data = array();
if ($aid) {
$this->assign('aid', $aid);
} else {
//用户的专辑
$album_list = M('album')->field('id,title')->where(array('uid' => $this->visitor->info['id']))->select();
//专辑分类
if (false === $album_cate_list = F('album_cate_list')) {
$album_cate_list = D('album_cate')->cate_cache();
}
$this->assign('album_cate_list', $album_cate_list);
$this->assign('album_list', $album_list);
}
//专辑分类
$data['html'] = $this->fetch('dialog:fetch_item');
$data['item'] = serialize($info['item']);
$this->ajaxReturn(1, L('fetch_item_success'), $data);
}
}我同时上传了php和模板文件,麻烦大神看看 附件 Item.rar ( 2.35 KB 下载:2 次 )
ThinkPHP 是一个免费开源的,快速、简单的面向对象的 轻量级PHP开发框架 ,创立于2006年初,遵循Apache2开源协议发布,是为了敏捷WEB应用开发和简化企业应用开发而诞生的。ThinkPHP从诞生以来一直秉承简洁实用的设计原则,在保持出色的性能和至简的代码的同时,也注重易用性。并且拥有众多的原创功能和特性,在社区团队的积极参与下,在易用性、扩展性和性能方面不断优化和改进,已经成长为国内最领先和最具影响力的WEB应用开发框架,众多的典型案例确保可以稳定用于商业以及门户级的开发。