文件地址: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已经调用,但是图片不显示。有会的帮忙处理下。

解决方案 »

  1.   

    你在浏览器中检查 url 是否正确
      

  2.   

    显示的<img src="">是空白。
      

  3.   

    那你就检查 $artciles_list 的内容
      

  4.   

    该调用的都测试了,还是不行。 /* ------------------------------------------------------ */    //-- 文章列表
        /* ------------------------------------------------------ */
        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里面还是空白。
      

  5.   

    四楼第十行后边print_r($artciles_list)看看,确定一下file_url有没有值,没有的话往前查model('ArticleBase')->get_cat_articles()
      

  6.   

    已经引用了:$artciles_list = model('ArticleBase')->get_cat_articles($this->cat_id, $this->page, $this->size, $this->keywords, $this->file_url);参数,就是不显示。能帮忙写下吗?
      

  7.   

    在 $this->assign('artciles_list', $artciles_list); 这里
     print_r($artciles_list); 看看是什么
      

  8.   

    $this->assign('artciles_list',print_r($artciles_list));还是不可以。
      

  9.   

    好了,你的模板里是 <img src="{$article.file_url}"> 
    关联键 file_url 在 你的 $artciles_list 中存在吗?反正你打印出来的没有
    既然没有,图片怎么会有呢
      

  10.   

    小白一枚,才
    小白一枚,刚学php不是怎么很理解
      

  11.   

    当学 php,就要从基础学起
    而不是用什么搭建空中楼阁的框架
      

  12.   

    这是get_cat_articles的内容    /**
         * 获得文章分类下的文章列表
         * 
         * @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