文件地址:include\apps\default\controllers\ArticleController.class.phppublic function art_list() {
$this->parameter();
$this->assign('keywords', $this->keywords);
$this->assign('id', $this->cat_id);
$artciles_list = model('ArticleBase')->get_cat_articles($this->cat_id, $this->page, $this->size, $this->keywords, $this->file_url);
$count = model('ArticleBase')->get_article_count($this->cat_id, $this->keywords, $this->file_url);
$this->pageLimit(url('art_list', array('id' => $this->cat_id)), $this->size, $this->file_url);
$this->assign('pager', $this->pageShow($count));
$this->assign('artciles_list', $artciles_list);
//处理关键词描述
$sql = "select * from ".M()->pre."article_cat where cat_id = ".$this->cat_id;
$cat = M()->query($sql);
if (!empty($cat['0']['keywords'])) {
$this->assign('meta_keywords',htmlspecialchars($cat['0']['keywords']));
}
if (!empty($cat['0']['cat_desc'])) {
$this->assign('meta_description',htmlspecialchars($cat['0']['cat_desc']));
}
$this->display('article_list.dwt');
}文章调用:
<!--{foreach from=$artciles_list item=article}-->
<img src="{$article.file_url}"> <a href="{$article.url}" >{$article.short_title}</a>
<!--{/foreach}-->
$article.file_url已经调用,但是图片不显示。有会的帮忙处理下。
$this->parameter();
$this->assign('keywords', $this->keywords);
$this->assign('id', $this->cat_id);
$artciles_list = model('ArticleBase')->get_cat_articles($this->cat_id, $this->page, $this->size, $this->keywords, $this->file_url);
$count = model('ArticleBase')->get_article_count($this->cat_id, $this->keywords, $this->file_url);
$this->pageLimit(url('art_list', array('id' => $this->cat_id)), $this->size, $this->file_url);
$this->assign('pager', $this->pageShow($count));
$this->assign('artciles_list', $artciles_list);
//处理关键词描述
$sql = "select * from ".M()->pre."article_cat where cat_id = ".$this->cat_id;
$cat = M()->query($sql);
if (!empty($cat['0']['keywords'])) {
$this->assign('meta_keywords',htmlspecialchars($cat['0']['keywords']));
}
if (!empty($cat['0']['cat_desc'])) {
$this->assign('meta_description',htmlspecialchars($cat['0']['cat_desc']));
}
$this->display('article_list.dwt');
}文章调用:
<!--{foreach from=$artciles_list item=article}-->
<img src="{$article.file_url}"> <a href="{$article.url}" >{$article.short_title}</a>
<!--{/foreach}-->
$article.file_url已经调用,但是图片不显示。有会的帮忙处理下。
解决方案 »
- 修改zencart网站遇到一些问题,求高手指教
- CKEditor 3.3 开启文件上传功能?请教!
- 在eclipse中编辑php怎么debug?
- 想用php制作网站,学了HTML, CSS , Javascript , PHP , MYSQL还应该学哪些呢?
- 想用php做个购物网站btoc,但不知道怎么架构
- php页面定时刷新读取数据库内容,并现实在该页面
- 北京市民免费注射甲流疫苗,明摆着对外地人的歧视嘛
- 注册页面出现Column count doesn't match value count at row 1
- 关于Zend Studio与php的关系等问题
- swf2pic flash生成缩略图的组件 本地服务器测试可用,放到网站服务器上直接报错?
- discuz添加自定义分类字段不会调用
- ||跟or的区别
/* ------------------------------------------------------ */
public function art_list() {
$this->parameter();
$this->assign('keywords', $this->keywords);
$this->assign('keywords', $this->keywords);
$this->assign('id', $this->cat_id);
$artciles_list = model('ArticleBase')->get_cat_articles($this->cat_id, $this->page, $this->size, $this->keywords, $this->file_url);
$count = model('ArticleBase')->get_article_count($this->cat_id, $this->keywords);
$this->pageLimit(url('art_list', array('id' => $this->cat_id)), $this->size);
$this->assign('pager', $this->pageShow($count));
$this->assign('artciles_list', $artciles_list);
//处理关键词描述
$sql = "select * from ".M()->pre."article_cat where cat_id = ".$this->cat_id;
$cat = M()->query($sql);
if (!empty($cat['0']['keywords'])) {
$this->assign('meta_keywords',htmlspecialchars($cat['0']['keywords']));
}
if (!empty($cat['0']['cat_desc'])) {
$this->assign('meta_description',htmlspecialchars($cat['0']['cat_desc']));
}
$this->display('article_list.dwt');
}调用的{$article.file_url}在列表的html里面还是空白。
print_r($artciles_list); 看看是什么
关联键 file_url 在 你的 $artciles_list 中存在吗?反正你打印出来的没有
既然没有,图片怎么会有呢
小白一枚,刚学php不是怎么很理解
而不是用什么搭建空中楼阁的框架
* 获得文章分类下的文章列表
*
* @access public
* @param integer $cat_id
* @param integer $page
* @param integer $size
* @return array
*/
public function get_cat_articles($cat_id, $page = 1, $size = 20, $requirement = '') {
// 取出所有非0的文章
if ($cat_id == '-1') {
$cat_str = 'cat_id > 0';
} else {
$cat_str = get_article_children($cat_id);
}
$condition = 'is_open = 1 AND ' . $cat_str;
// 增加搜索条件,如果有搜索内容就进行搜索
if ($requirement != '') {
$condition .= ' AND title like \'%' . $requirement . '%\'';
}
$limit = ($page - 1) * $size . ',' . $size;
$list = $this->select($condition, 'article_id, title, author, add_time, file_url, open_type,link', ' article_id DESC', $limit); $i = 1;
$arr = array();
if (is_array($list)) {
foreach ($list as $vo) {
$article_id = $vo['article_id'];
$arr[$article_id]['id'] = $article_id;
$arr[$article_id]['index'] = $i;
$arr[$article_id]['title'] = $vo['title'];
$arr[$article_id]['short_title'] = C('article_title_length') > 0 ? sub_str($vo['title'], C('article_title_length')) : $vo['title'];
$arr[$article_id]['author'] = empty($vo['author']) || $vo['author'] == '_SHOPHELP' ? C('shop_name') : $vo['author'];
$arr[$article_id]['url'] = $vo['link'] ? $vo['link'] : url('article/info', array('aid' => $article_id)) ;
$arr[$article_id]['add_time'] = date(C('date_format'), $vo['add_time']);
$i++;
}
}
return $arr;
}看返回的数组处理过程 $i = 1;
$arr = array();
if (is_array($list)) {
foreach ($list as $vo) {
$article_id = $vo['article_id'];
$arr[$article_id]['id'] = $article_id;
$arr[$article_id]['index'] = $i;
$arr[$article_id]['title'] = $vo['title'];
$arr[$article_id]['short_title'] = C('article_title_length') > 0 ? sub_str($vo['title'], C('article_title_length')) : $vo['title'];
$arr[$article_id]['author'] = empty($vo['author']) || $vo['author'] == '_SHOPHELP' ? C('shop_name') : $vo['author'];
$arr[$article_id]['url'] = $vo['link'] ? $vo['link'] : url('article/info', array('aid' => $article_id)) ;
$arr[$article_id]['add_time'] = date(C('date_format'), $vo['add_time']);
$i++;
}
}
return $arr;返回的数组只有id、index、title、short_title、author、url、add_time,没了。这是固定的,调用该方法的时候,你再加什么参数都没用,返回的数组都是固定这些值。需要的时候,这些文件又不是不能改,你需要这个字段,就在这里改就行了。
include/base/model/ArticleBaseModel.class.php