01-03-2023, 12:52 AM
(This post was last modified: 01-03-2023, 12:56 AM by webidsupport.)
This mod (WeBid version 0.7.4) will display in the home page a number of items (10, 15, 20, 25, 50 or the number that you prefer) sorted by: Ending soon, higher price, low price, last created and, buy it now or only auctions. To include this mod, first you have to include hotmod (Credits to Renlok). The steps to make the mod:
1. Create a file with name items_sorted_as.inc.php in language/EN with code:
2. Create a file with name numitems.inc.php in includes with code
3. Open header.php and find:
and replace with
4. Open index.php add this lines of code
Find:
Add after:
The next code is my modification of hotmod... At the time of this post, the hotmod had not been migrated.
5. Including the select boxes in your html. Edit in themes/default/global_header.html
Find:
Add after:
If any error or improvement is found in the code, please say me.
1. Create a file with name items_sorted_as.inc.php in language/EN with code:
Code:
<select name="sort">
<option value="0">Ending soon</option>
<option value="1">Higher price</option>
<option value="2">Low price</option>
<option value="3">Last created</option>
<option value="4">Buy it now</option>
<option value="5">Only Auctions</option>
</select>
Code:
<select name="items">
<option value="10">10</option>
<option value="15">15</option>
<option value="20">20</option>
<option value="25">25</option>
<option value="50">50</option>
</select>
3. Open header.php and find:
Code:
'B_BOARDS' => ($system->SETTINGS['boards'] == 'y' && $system->SETTINGS['boardslink'] == 'y')
and replace with
Code:
B_BOARDS' => ($system->SETTINGS['boards'] == 'y' && $system->SETTINGS['boardslink'] == 'y'),
'SELBOX_NITEMS' => file_get_contents($main_path . "includes/numitems.inc.php"),
'SELBOX_SORT_AS' => file_get_contents($main_path . "language/" . $language . "/items_sorted_as.inc.php"),
4. Open index.php add this lines of code
Find:
Code:
require('includes/config.inc.php');
include $main_path . 'language/' . $language . '/categories.inc.php';
Add after:
Code:
$params['items'] = (isset($_GET['items'])) ? $_GET['items'] : 10;
$items = intval($params['items']);
$params['sort'] = (isset($_GET['sort'])) ? $_GET['sort'] : 0;
$sort = intval($params['sort']);
switch ($sort) {
case 0: $sorted = 'a.ends ASC'; $buyitnow = '';
break;
case 1: $sorted = 'a.minimum_bid ASC'; $buyitnow = '';
break;
case 2: $sorted = 'a.current_bid ASC'; $buyitnow = '';
break;
case 3: $sorted = 'a.starts DESC'; $buyitnow = '';
break;
case 4: $sorted = 'a.buy_now DESC'; $buyitnow = 'AND buy_now > 0 ';
break;
case 5: $sorted = 'a.ends ASC'; $buyitnow = 'AND buy_now = 0 ';
break;
}
The next code is my modification of hotmod... At the time of this post, the hotmod had not been migrated.
Code:
//hotmod
$query = "SELECT a.id, a.title, a.current_bid, a.pict_url,a.starts, a.ends, a.num_bids, a.minimum_bid, a.buy_now
FROM " . $DBPrefix . "auctions a
WHERE closed = 0 AND suspended = 0 " . $buyitnow . "AND starts <= " . $NOW . "
ORDER BY " . $sorted . " LIMIT " . $items;
$res = mysql_query($query);
$system->check_mysql($res, $query, __LINE__, __FILE__);
$bgcolor = '#FFFFFF';
while($row = mysql_fetch_assoc($res)) {
$ends = $row['ends'];
$difference = $ends - time();
if ($difference > 0) {
$ends_string = FormatTimeLeft($difference);
} else {
$ends_string = $MSG['911'];
}
if ($bgcolor == '#FFFFFF') {
$bgcolor = '#FFFDDD';
} else {
$bgcolor = '#FFFFFF';
}
$high_bid = ($row['num_bids'] == 0) ? $row['minimum_bid'] : $row['current_bid'];
$template->assign_block_vars('hotmod', array(
'BGCOLOUR' => $bgcolor,
'STARTS' => ArrangeDateNoCorrection($row['starts']),
'ENDS' => $ends_string,
'ID' => $row['id'],
'BID' => $system->print_money($high_bid),
'IMAGE' => (!empty($row['pict_url'])) ? '<img src="' . $system->SETTINGS['siteurl'] . 'getthumb.php?w=' . $system->SETTINGS['thumb_show'] . '&fromfile=' . $uploaded_path . $row['id'] . '/' . $row['pict_url'] . '">' : '<img src="' . $system->SETTINGS['siteurl'] . 'language/' . $language .'/img/nopicture.gif">',
'TITLE' => $row['title'],
'NBIDS' => $row['num_bids'],
'BUYNOW' => ($row['buy_now'] > 0) ? '<img src="' . $system->SETTINGS['siteurl'] . 'language/' . $language .'/img/buy_it_now.gif">' : ''
));
}
5. Including the select boxes in your html. Edit in themes/default/global_header.html
Find:
Code:
<td width="50%" align="right">
<form name="gobrowse" action="{SITEURL}browse.php" method="GET">
<div class="barBrowse">
{L_104}
{SELECTION_BOX}
<input type="submit" name="sub" value="{L_275}" class="button">
</div>
</form>
Code:
<form name="numitems" action="{SITEURL}index.php" method="GET">
<div class="barBrowse">
{L_104}
{SELBOX_NITEMS}
{SELBOX_SORT_AS}
<input type="submit" name="sub" value="{L_275}" class="button">
</div>
</form>
If any error or improvement is found in the code, please say me.