I have a website which goes on Joomla 3 and PHP Smarty Framework (in which the component is written)
It is Auction site and I currently have some issues with the Smarty...
Here's the deal - When user is logged on, the site shows all his bids, in the bid history, marked as orange.
I would like the site to show marked bid in orange ONLY if you have the highest bid. If not - nothing...
Here is the excerpt from that part of the code:
{if $bid->userid==$userid}
{assign var="tr_class" value="auction_bids_mybid1"}
<a name = 'mybid' id = 'mybid'></a>
{/if}
This uses the variables from the GetBestMethod from some other file:
public function GetBestBid($userid = FALSE)
{
$db = JFactory::getDbo();
$query = "SELECT * FROM #__bids AS b WHERE auction_id='$this->id' " . ($userid ? (' AND userid=' . $userid) : '') . " ORDER BY bid_price DESC";
$db->setQuery($query, 0, 1);
$res = $db->loadObject();
if (!$res) {
$query = "SELECT * FROM `#__bids` AS `b` WHERE `auction_id`='$this->id' ORDER BY `bid_price` DESC";
$db->setQuery($query, 0, 1);
$res = $db->loadObject();
}
return $res;
}
So, basically long story short:
if current user has the highest bid then mark the bid else nothing.
I found the solution: In order to mark only the highest (top) bid you have to just add this:
{if $bid->userid==$userid && $smarty.foreach.bids.index == 0}
That's it ;)