На странице пользователя вывел кусочек фотоленты
This commit is contained in:
parent
dcfe9258c7
commit
ab04c51680
|
|
@ -43,9 +43,12 @@ class UserController extends Controller
|
|||
$randomPoint->description = mb_substr($randomPoint->description, 0, 400, 'UTF-8');
|
||||
$randomPoint->description = Helper::replaceLinks($randomPoint->description);
|
||||
|
||||
$photos = ArticlePhotos::model()->getByUser($id, 5);
|
||||
|
||||
self::render('user/index.php', array(
|
||||
'user' => $user,
|
||||
'articles' => $articles,
|
||||
'photos' => $photos,
|
||||
'imAuthor' => App::$user && App::$user->id == $id,
|
||||
'randomPoint' => $randomPoint,
|
||||
));
|
||||
|
|
|
|||
|
|
@ -15,4 +15,16 @@ class ArticlePhotos extends Model
|
|||
return new self();
|
||||
}
|
||||
|
||||
function getByUser($userId, $limit = 0)
|
||||
{
|
||||
$params = array(
|
||||
'where' => '`owner` = '.(int)$userId,
|
||||
);
|
||||
|
||||
if ($limit > 0) {
|
||||
$params['limit'] = (int) $limit;
|
||||
}
|
||||
|
||||
return $this->getAll($params);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,12 +16,12 @@
|
|||
<div class="row">
|
||||
<div class="col-md-12 articlesList">
|
||||
|
||||
<h2>Статьи: </h2>
|
||||
<h2>Записи: </h2>
|
||||
|
||||
<?php if ($articles): foreach ($articles as $article): ?>
|
||||
<div class="article">
|
||||
<a href="/article/<?= $article->id ?>" target="_blank" class="h">
|
||||
<?php if($article->photoId): ?>
|
||||
<?php if ($article->photoId): ?>
|
||||
<img src="<?= $article->getImg() ?>" />
|
||||
<?php else: ?>
|
||||
<img src="/img/noPhoto200150.png" />
|
||||
|
|
@ -31,13 +31,29 @@
|
|||
<?= mb_substr(Markdown::getClear(str_replace('"', 'ʺ', $article->text)), 0, 250, 'UTF-8') ?>…
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
<?php endforeach;
|
||||
else: ?>
|
||||
Пока нет статей.
|
||||
<?php endif;?>
|
||||
<?php endforeach; ?>
|
||||
<?php else: ?>
|
||||
В блоге пока пусто.
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if ($photos): ?>
|
||||
<div class="row">
|
||||
<div class="col-md-12 photoList">
|
||||
<h2>Фотолента:</h2>
|
||||
<div style="text-align: center;">
|
||||
<?php foreach ($photos as $photo): ?>
|
||||
<div class="photo">
|
||||
<img src="/photos/articles/small/<?= $photo->name ?>" />
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<hr style="margin-bottom: 50px;"/>
|
||||
<!--googleoff: all-->
|
||||
<!--noindex-->
|
||||
|
|
|
|||
|
|
@ -11,3 +11,6 @@
|
|||
.articlesList .article {border: solid 1px #ddd; border-radius: 3px; padding: 4px; margin-bottom: 5px;background-color: rgba(255,255,255, 0.8);}
|
||||
.articlesList .article img {width: 100px; float: left; margin-right: 10px;}
|
||||
.articlesList .article .h {font-size: 18px; font-weight: bold; display: block;}
|
||||
|
||||
.photoList {}
|
||||
.photoList .photo {display: inline-block; border: solid 3px #fff; margin: 3px;}
|
||||
|
|
|
|||
Loading…
Reference in New Issue