Author Topic: Shop: Display last added item first (on top)  (Read 2160 times)

Offline Vincent Volmer

Shop: Display last added item first (on top)
« on: January 06, 2008, 11:38:43 pm »
Hello,

Is there a possibility to display the last added item at the top. So it is not sorted by name or description but by date?


Regards,
Vincent Volmer

Offline Daniel15

Re: Shop: Display last added item first (on top)
« Reply #1 on: February 15, 2008, 07:22:26 am »
Sorry for the delay in replying...

Sure, this is possible to add :)
Sources/shop/Shop-Buy.php, find:
Code: [Select]
case 3:
$context['shop_inv']['sort_type'] = $txt['shop_stock'];
$sortQuery = 'stock';
Add after:
Code: [Select]
case 4:
$context['shop_inv']['sort_type'] = 'Date added';
$sortQuery = 'id';

Themes/default/Shop.template.php, find:
Code: [Select]
<option value="3"', ($context['shop_inv']['sort_type'] == $txt['shop_stock'] ? ' selected="selected"' : ''), '>', $txt['shop_stock'], '</option>Add after:
Code: [Select]
<option value="4"', ($context['shop_inv']['sort_type'] == 'Date added' ? ' selected="selected"' : ''), '>Date added</option>

This will add a "date added" option to the sort box on the buy items page. If you want to call it something else, change "date added" to whatever you want to call it (it occurs three times in the above code sections)

Offline Vincent Volmer

Re: Shop: Display last added item first (on top)
« Reply #2 on: February 15, 2008, 01:54:19 pm »
Sorry for the delay in replying...
No problem!  :D

Thanks for your answer. It works great  O0

When I go into the shop the list of items is default ordered by name. Is it also possible to change this to 'Date added' , and see the last added item on top of the list?

Regards Vincent