'normal'];
if ($name !== '') {
$where['name'] = $name;
}
$order = $orderby == 'rand' ? 'rand()' : (in_array($orderby, ['name', 'id', 'createtime', 'updatetime', 'weigh']) ? "{$orderby} {$orderway}" : "id {$orderway}");
$list = self::where($where)
->where($condition)
->field($field)
->order($order)
->limit($limit)
->cache($cache)
->select();
self::render($list, $imgwidth, $imgheight);
return $list;
}
public static function render(&$list, $imgwidth, $imgheight)
{
$width = $imgwidth ? 'width="' . $imgwidth . '"' : '';
$height = $imgheight ? 'height="' . $imgheight . '"' : '';
foreach ($list as $k => &$v) {
$v['hasimage'] = $v->getData('image') ? true : false;
$v['textlink'] = '' . $v['title'] . '';
$v['imglink'] = '';
$v['img'] = '';
}
return $list;
}
public static function getBlockContent($params)
{
$field = isset($params['id']) ? 'id' : 'name';
$value = isset($params[$field]) ? $params[$field] : '';
$cache = !isset($params['cache']) ? true : (int)$params['cache'];
$row = self::where($field, $value)
->where('status', 'normal')
->cache($cache)
->find();
$result = '';
if ($row) {
if ($row['content']) {
$result = $row['content'];
} elseif ($row['image']) {
$result = '';
} else {
$result = $row['title'];
}
if ($row['url'] && !$row['content']) {
$result = $row['url'] ? '' . $result . '' : $result;
}
}
return $result;
}
}