Вывод похожих точек на странице точки

This commit is contained in:
Krivchikov Dmitry 2014-10-08 00:29:55 +04:00
parent 1d66404972
commit da205d6e93
2 changed files with 6 additions and 5 deletions

View File

@ -69,11 +69,12 @@ class PageController extends Controller
$point->categoryName = $categories[$point->categoryId]['name']; $point->categoryName = $categories[$point->categoryId]['name'];
$randomPoint = Point::model()->getRandom(); $randomPoint = Point::model()->getRandom();
// print_r($randomPoint->name); $similarPoints = Point::model()->getAll(array('where' => 'categoryId = '.$point->categoryId.' AND `id` <> '.$point->id.' ORDER BY RAND() LIMIT 6;'));
self::render('point.php', array( self::render('point.php', array(
'point' => $point, 'point' => $point,
'randomPoint' => $randomPoint, 'randomPoint' => $randomPoint,
'similarPoints' => $similarPoints,
'categories' => $categories, 'categories' => $categories,
'photos' => $point->photos, 'photos' => $point->photos,
)); ));

View File

@ -9,7 +9,7 @@
<!-- <p><span class="glyphicon glyphicon-thumbs-up"></span> 10 - рейтинг</p>--> <!-- <p><span class="glyphicon glyphicon-thumbs-up"></span> 10 - рейтинг</p>-->
<hr/> <hr/>
<h3><?= $randomPoint->name ?></h3> <h3><?= $randomPoint->name ?></h3>
<p style="text-align: center;"><a href="/page/point/id/41"><img src="<?= $randomPoint->getImg() ?>" style="width: 200px;"/></a></p> <p style="text-align: center;"><a href="/page/point/id/<?= $randomPoint->id ?>"><img src="<?= $randomPoint->getImg() ?>" style="width: 200px;"/></a></p>
<p> <p>
<?= mb_substr($randomPoint->description, 0, 120, 'UTF-8') ?>... <?= mb_substr($randomPoint->description, 0, 120, 'UTF-8') ?>...
<a class="" href="/page/point/id/<?= $randomPoint->id ?>" role="button"><nobr>далее »</nobr></a> <a class="" href="/page/point/id/<?= $randomPoint->id ?>" role="button"><nobr>далее »</nobr></a>
@ -103,8 +103,8 @@
<p><img src="/photos/small/305_337c1.jpg" style="width: 105px;"/> <img src="/photos/small/300_81352.jpg" style="width: 105px;"/></p> <p><img src="/photos/small/305_337c1.jpg" style="width: 105px;"/> <img src="/photos/small/300_81352.jpg" style="width: 105px;"/></p>
<hr/> <hr/>
<h2>Похожие:</h2> <h2>Похожие:</h2>
<p><img src="/photos/small/41_4cd05.jpg" style="width: 105px;"/> <img src="/photos/small/35_2f786.jpg" style="width: 105px;"/></p> <?php foreach ($similarPoints as $sPoint): ?>
<p><img src="/photos/small/90_3e312.jpg" style="width: 105px;"/> <img src="/photos/small/271_3f479.jpg" style="width: 105px;"/></p> <a href="/page/point/id/<?= $sPoint->id ?>"><img src="<?= $sPoint->getImg()?>" title="<?= $sPoint->name ?>" style="width: 105px;"/></a>
<p><img src="/photos/small/303_85515.jpg" style="width: 105px;"/> <img src="/photos/small/298_206be.jpg" style="width: 105px;"/></p> <?php endforeach;?>
</div> </div>
</div> </div>