Chciałbym zrobić na swojej stronie głównej aby wyświetlały się tylko ogłoszenia promowane przez użytkowników.
Może ktoś pomoże mi przerobić poniższy kod, aby na stronie głównej wyświetlane były tylko oferty promowane, ale rotacyjnie to znaczy przy każdym odświeżeniu strony mają się pojawiać losowo ogłoszenia promowane. Coś takiego jak jest na stronie oferty-dom.pl
Kod
<?php
if(!empty($this->advertisements)) {
echo '<table class="advTop" cellspacing="0" cellpadding="0" border="0">
<tr>
<td class="advTopCam"><center> <img src="public/images/camera.gif" alt=""/></center></td>
<td class="advTopType"> <b>typ nieruchomości</b><br/> typ ogłoszenia</td>
<td class="advTopSize"><b>powierzchnia</b></td>
<td class="advTopPrice"><b>cena</b></td>
<td class="advTopPro"> <b>województwo</b><br/> miasto</td>
<td class="advTopDate"> <b>data dodania</b></td>
</tr>
</table>
<table style="margin-top:5px;" cellpadding="0" cellspacing="0">';
foreach($this->advertisements as $advertisement) {
if($advertisement->promo) { ///////////////////////////////////////////////////////////////// promo advertise
echo '<tr >
<td>
<a href="adv/show/'.StringModifier::FriendlyUrl($advertisement->advertisementType).'/'.StringModifier::FriendlyUrl($advertisement->propertyType).'/'.StringModifier::FriendlyUrl($advertisement->province).'/'.$advertisement->id.'.html"><img src="public/images/';
if(!empty($advertisement->image))
echo 'advertisements/'.$advertisement->image.'_thumb.jpg';
else
echo 'photo.gif';
echo '" class="photoPromo" alt=""/></a>
</td>
<td style="padding-top:5px;" valign="top">
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td class="offerTypePromo">
<img src="public/images/p.gif" style="float:left;margin-right:5px;" alt=""/> <a href="adv/show/'.StringModifier::FriendlyUrl($advertisement->advertisementType).'/'.StringModifier::FriendlyUrl($advertisement->propertyType).'/'.StringModifier::FriendlyUrl($advertisement->province).'/'.$advertisement->id.'.html"><b>'.mb_strtoupper($advertisement->propertyType, "UTF-8").'</b><br/>'.$advertisement->advertisementType.'</a>
</td>
<td class="offerSizePromo">
'.$advertisement->areaSize.' m<sup><small>2</small></sup>
</td>
<td class="offerPricePromo">';
if($advertisement->price > 0)
echo $advertisement->price.' zł';
else
echo 'b/d';
echo '</td>
<td class="offerProvincePromo">
<b>'.$advertisement->province.'</b><br/>
'.$advertisement->city.'
</td>
<td class="offerDatePromo">
'.$advertisement->announceDate.'
</td>
</tr>
<tr>
<td colspan="4" class="offerDescPromo" valign="top">
'.StringModifier::Cut($advertisement->description, 40).' (...)
</td>
<td class="offerMorePromo" valign="top">
<a href="adv/show/'.StringModifier::FriendlyUrl($advertisement->advertisementType).'/'.StringModifier::FriendlyUrl($advertisement->propertyType).'/'.StringModifier::FriendlyUrl($advertisement->province).'/'.$advertisement->id.'.html"><img src="public/images/more.gif" alt="" style="margin-top:2px;padding:0px;"/></a><br/>';
if($this->user->admin) // admin menu
echo ' <a href="account/edit/'.$advertisement->id.'"><img src="public/images/edit.gif" alt="" style="margin-top:2px;padding:0px;"/></a><br/> <a href="account/delete/'.$advertisement->id.'"><img src="public/images/delete.gif" alt="" style="margin-top:2px;padding:0px;"/></a><br/>';
echo '</td>
</tr>
</table>
</td>
</tr>';
} else { ///////////////////////////////////////////////////////////////// none
echo '';
}
}
echo '</table>';
}
?>
if(!empty($this->advertisements)) {
echo '<table class="advTop" cellspacing="0" cellpadding="0" border="0">
<tr>
<td class="advTopCam"><center> <img src="public/images/camera.gif" alt=""/></center></td>
<td class="advTopType"> <b>typ nieruchomości</b><br/> typ ogłoszenia</td>
<td class="advTopSize"><b>powierzchnia</b></td>
<td class="advTopPrice"><b>cena</b></td>
<td class="advTopPro"> <b>województwo</b><br/> miasto</td>
<td class="advTopDate"> <b>data dodania</b></td>
</tr>
</table>
<table style="margin-top:5px;" cellpadding="0" cellspacing="0">';
foreach($this->advertisements as $advertisement) {
if($advertisement->promo) { ///////////////////////////////////////////////////////////////// promo advertise
echo '<tr >
<td>
<a href="adv/show/'.StringModifier::FriendlyUrl($advertisement->advertisementType).'/'.StringModifier::FriendlyUrl($advertisement->propertyType).'/'.StringModifier::FriendlyUrl($advertisement->province).'/'.$advertisement->id.'.html"><img src="public/images/';
if(!empty($advertisement->image))
echo 'advertisements/'.$advertisement->image.'_thumb.jpg';
else
echo 'photo.gif';
echo '" class="photoPromo" alt=""/></a>
</td>
<td style="padding-top:5px;" valign="top">
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td class="offerTypePromo">
<img src="public/images/p.gif" style="float:left;margin-right:5px;" alt=""/> <a href="adv/show/'.StringModifier::FriendlyUrl($advertisement->advertisementType).'/'.StringModifier::FriendlyUrl($advertisement->propertyType).'/'.StringModifier::FriendlyUrl($advertisement->province).'/'.$advertisement->id.'.html"><b>'.mb_strtoupper($advertisement->propertyType, "UTF-8").'</b><br/>'.$advertisement->advertisementType.'</a>
</td>
<td class="offerSizePromo">
'.$advertisement->areaSize.' m<sup><small>2</small></sup>
</td>
<td class="offerPricePromo">';
if($advertisement->price > 0)
echo $advertisement->price.' zł';
else
echo 'b/d';
echo '</td>
<td class="offerProvincePromo">
<b>'.$advertisement->province.'</b><br/>
'.$advertisement->city.'
</td>
<td class="offerDatePromo">
'.$advertisement->announceDate.'
</td>
</tr>
<tr>
<td colspan="4" class="offerDescPromo" valign="top">
'.StringModifier::Cut($advertisement->description, 40).' (...)
</td>
<td class="offerMorePromo" valign="top">
<a href="adv/show/'.StringModifier::FriendlyUrl($advertisement->advertisementType).'/'.StringModifier::FriendlyUrl($advertisement->propertyType).'/'.StringModifier::FriendlyUrl($advertisement->province).'/'.$advertisement->id.'.html"><img src="public/images/more.gif" alt="" style="margin-top:2px;padding:0px;"/></a><br/>';
if($this->user->admin) // admin menu
echo ' <a href="account/edit/'.$advertisement->id.'"><img src="public/images/edit.gif" alt="" style="margin-top:2px;padding:0px;"/></a><br/> <a href="account/delete/'.$advertisement->id.'"><img src="public/images/delete.gif" alt="" style="margin-top:2px;padding:0px;"/></a><br/>';
echo '</td>
</tr>
</table>
</td>
</tr>';
} else { ///////////////////////////////////////////////////////////////// none
echo '';
}
}
echo '</table>';
}
?>
Pozdrawiam i z góry dziękuję za wszelką pomoc.