Вывод ссылок на статьи, в которых упоминается точка

This commit is contained in:
Krivchikov Dmitry 2015-09-18 18:30:52 +03:00
parent c659368459
commit 78a6d50b9a
4 changed files with 27 additions and 3 deletions

View File

@ -75,6 +75,16 @@ class PointController extends Controller
$randomPoint->description = mb_substr($randomPoint->description, 0, 400, 'UTF-8'); $randomPoint->description = mb_substr($randomPoint->description, 0, 400, 'UTF-8');
$randomPoint->description = Helper::replaceLinks($randomPoint->description); $randomPoint->description = Helper::replaceLinks($randomPoint->description);
$articlePoints = ArticlePoints::model()->getAll(array('where'=>'`pointId` = '.$pointId));
$articleIds = array();
$articles = array();
if ($articlePoints) {
foreach ($articlePoints as $articlePoint) {
$articleIds[] = (int)$articlePoint->articleId;
}
$articles = Article::model()->getAll(array('where'=>'`id` IN ('. implode(',', $articleIds).')'));
}
self::render('point.php', array( self::render('point.php', array(
'point' => $point, 'point' => $point,
'text' => $items[0], 'text' => $items[0],
@ -88,6 +98,7 @@ class PointController extends Controller
'og' => Helper::buildOG($point), 'og' => Helper::buildOG($point),
'user' => App::$user, 'user' => App::$user,
'photoLinks' => $photoLinksRes, 'photoLinks' => $photoLinksRes,
'articles' => $articles,
)); ));
} else { } else {
App::error404(); App::error404();

View File

@ -28,7 +28,7 @@ class Article extends Model
} }
return '/img/logo.png'; return $size == 'small' ? '/img/noPhoto200150.png' : '/img/logo.png';
} }
} }

View File

@ -89,9 +89,20 @@ $index = 0;
<hr/> <hr/>
<!--googleoff: all--> <!--googleoff: all-->
<!--noindex--> <!--noindex-->
<?php if ($articles): ?>
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<h3 style="margin-top: 0;">Поблизости:</h3> <h3 style="margin-top: 0;">Эта точка в статьях:</h3>
<?php foreach ($articles as $article): ?>
<a href="/article/<?= $article->id ?>" class="pagePoinsNearCards"><img src="<?= $article->getImg('small') ?>" title="<?= $article->title ?>" class="pagePoinsNearCardsImg"/></a>
<?php endforeach; ?>
</div>
</div>
<hr/>
<?php endif; ?>
<div class="row">
<div class="col-md-12">
<h3 style="margin-top: 0;">Поблизости расположены:</h3>
<?php if (empty($closestPoints)): ?> <?php if (empty($closestPoints)): ?>
нет известных нам точек. нет известных нам точек.
<?php else: ?> <?php else: ?>
@ -100,13 +111,15 @@ $index = 0;
</div> </div>
</div> </div>
<hr/> <hr/>
<?php if (!$articles): ?>
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<h3 style="margin-top: 0;">Похожие:</h3> <h3 style="margin-top: 0;">Похожие точки:</h3>
<?php foreach ($similarPoints as $sPoint): ?><a href="/point/<?= $sPoint->id ?>" class="pagePoinsNearCards"><img src="<?= $sPoint->getImg() ?>" title="<?= $sPoint->name ?>" class="pagePoinsNearCardsImg"/></a><?php endforeach; ?> <?php foreach ($similarPoints as $sPoint): ?><a href="/point/<?= $sPoint->id ?>" class="pagePoinsNearCards"><img src="<?= $sPoint->getImg() ?>" title="<?= $sPoint->name ?>" class="pagePoinsNearCardsImg"/></a><?php endforeach; ?>
</div> </div>
</div> </div>
<hr/> <hr/>
<?php endif; ?>
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<a href="/point/<?= $randomPoint->id ?>" style="float: left; margin: 0 20px 0 0;"><img src="<?= $randomPoint->getImg() ?>" style="width: 200px;"/></a> <a href="/point/<?= $randomPoint->id ?>" style="float: left; margin: 0 20px 0 0;"><img src="<?= $randomPoint->getImg() ?>" style="width: 200px;"/></a>

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB