public function getBlogs($name = '', $options = array())
{
$options = array_merge(array('sort' => 'BlogContent.id', 'siteId' => 0), $options);
$conditions['Content.status'] = true;
if (!empty($name)) {
$conditions['Content.name'] = $name;
}
if ($options['siteId'] !== '') {
$conditions['Content.site_id'] = $options['siteId'];
}
$BlogContent = ClassRegistry::init('Blog.BlogContent');
$BlogContent->unbindModel(['hasMany' => ['BlogPost', 'BlogCategory']]);
$datas = $BlogContent->find('all', array('conditions' => $conditions, 'order' => $options['sort'], 'cache' => false));
if (!$datas) {
return false;
}
$contents = array();
if (count($datas) === 1) {
$datas = $BlogContent->constructEyeCatchSize($datas[0]);
unset($datas['BlogContent']['eye_catch_size']);
$contents[] = $datas;
} else {
foreach ($datas as $val) {
$val = $BlogContent->constructEyeCatchSize($val);
unset($val['BlogContent']['eye_catch_size']);
$contents[] = $val;
}
}
if ($name) {
$contents = $contents[0];
}
return $contents;
}