[英]Joomla and PHP Smarty Framework
我有一個網站,該網站使用Joomla 3和PHP Smarty Framework(在其中編寫了組件)
這是拍賣網站,我目前在Smarty方面存在一些問題。
這是交易-當用戶登錄時,網站在出價歷史記錄中顯示其所有出價,標記為橙色。
如果您的出價最高,我希望該網站僅顯示橙色標記的出價。 如果沒有-沒什么...
這是該部分代碼的摘錄:
{if $bid->userid==$userid}
{assign var="tr_class" value="auction_bids_mybid1"}
<a name = 'mybid' id = 'mybid'></a>
{/if}
這將使用其他文件中的GetBestMethod中的變量:
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;
}
所以,基本上長話短說:
如果當前用戶的出價最高,則將其標記為其他。
我找到了解決方案:為了只標記最高(最高)出價,您只需添加以下內容:
{if $bid->userid==$userid && $smarty.foreach.bids.index == 0}
而已 ;)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.