【问题标题】:Joomla and PHP Smarty FrameworkJoomla 和 PHP Smarty 框架
【发布时间】:2015-05-19 20:04:13
【问题描述】:

我有一个使用 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;

    }

所以,长话短说:

如果当前用户的出价最高,则不标记该出价。

【问题讨论】:

    标签: php joomla smarty


    【解决方案1】:

    我找到了解决方案:为了仅标记最高(最高)出价,您只需添加以下内容:

    {if $bid->userid==$userid && $smarty.foreach.bids.index == 0}
    

    就是这样;)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-09-07
      • 1970-01-01
      • 2014-02-14
      • 2010-11-27
      • 2012-02-22
      相关资源
      最近更新 更多