啊是经过 2011-05-07 11:50:37 4003次浏览 4条回复 0 0 0

在model写了这个方法

public static function gettitle(){
  $models=self::model()->findAll(array('order'=>'id asc'));
  $ltitle=array();
  foreach ($models as $model)
  {
    if($model->image==NULL){
      $ltitle[$model->id][$model->title]=$model->title;
      $ltitle[$model->id][$model->title]=$model->url;
      //$ltitle[$model->id][$model->title]=$model->image;
    }else{
      $ltitle[$model->id][$model->image]=$model->url;
      $ltitle[$model->id][$model->image]=$model->title;
      $ltitle[$model->id][$model->image]=$model->image;
    }
  }
  return $ltitle;
}

然后显示

<?php
$lltitle=link::gettitle();     
foreach($lltitle as $id=>$title)
foreach ($title as $key=>$value)
echo CHtml::link($key,$value).' ' ;?>

这个只显示文字,如果我想有图片只输出图片不显示文字,怎么改

您需要登录后才可以回复。登录 | 立即注册