You are here:  » Order by imported date


Order by imported date

Submitted by Peter on Wed, 2006-08-30 01:02 in

Hello David,

ist it possible to sort the feeds on the admin-page by imported date. i just test it with ... ORDER BY `imported` ASC .... in admin/index.php but it don´t work.

Cheers, Peter

Submitted by support on Wed, 2006-08-30 06:45

Hi Peter,

The feeds are actually displayed in whatever order the files are returned by the readdir() function - which depends on various external factors but is ultimately down to the servers' operating system.

The SQL is just used to build a lookup table that displays the various parameters alongside each filename as it is displayed. I'm afraid it would be quite tricky to change to the order because the entire script is built around the readdir() function.

Cheers,
David.

Submitted by Peter on Thu, 2006-08-31 01:53

Hello,

ok i understand.

But another question...

I want a link to sort the products by name. Like relevance, price ...

Is this possible?

Thanks, Peter

Submitted by support on Thu, 2006-08-31 05:27

Hi Peter,

To give a link to sort by product name, you need to add a couple of changes to search.php. Starting on line 14, you'll see the construction of an array containing SQL order by clauses. Add two lines for the new "Name" sort where indicated as follows:

<?php
    $orderByDefault 
= array();
    
$orderByDefault["rating"] = "rating DESC";
    
$orderByDefault["name"] = "name ASC"// NEW
    
$orderByDefault["priceAsc"] = "minPrice ASC";
    
$orderByDefault["priceDesc"] = "minPrice DESC";
    
$orderByFullText = array();
    
$orderByFullText["relevance"] = "relevance DESC";
    
$orderByFullText["name"] = "name ASC"// NEW
    
$orderByFullText["rating"] = "rating DESC";
    
$orderByFullText["priceAsc"] = "minPrice ASC";
    
$orderByFullText["priceDesc"] = "minPrice DESC";
?>

Then, you need to add the link to sort by name. I recommend adding if after the Relevance link, as Relevance is the default sort order. Add the new link where indicated below. This code starts on line 107 (before having made the above mods!)...

<?php
      $sortHREF 
$config_baseHREF."search.php?q=".urlencode($q)."&amp;page=1&amp;sort=";
      
$sortRelevance = ($sort=="relevance"?"<strong>".translate("Relevance")."</strong>":"<a href='".$sortHREF."relevance'>".translate("Relevance")."</a>");
      
// NEW - CONSTRUCT URL FOR NAME SORT
      
$sortName = ($sort=="name"?"<strong>".translate("Name")."</strong>":"<a href='".$sortHREF."name'>".translate("Name")."</a>");
      if (
$config_useInteraction)
      {
        
$sortRating ", ".($sort=="rating"?"<strong>".translate("Product Rating")."</strong>":"<a href='".$sortHREF."rating'>".translate("Product Rating")."</a>");
      }
      else
      {
        
$sortRating "";
      }
      
$sortPriceAsc = ($sort=="priceAsc"?"<strong>".translate("Low to High")."</strong>":"<a href='".$sortHREF."priceAsc'>".translate("Low to High")."</a>");
      
$sortPriceDesc = ($sort=="priceDesc"?"<strong>".translate("High to Low")."</strong>":"<a href='".$sortHREF."priceDesc'>".translate("High to Low")."</a>");
      
// MODIFIED - ADD THE LINK FOR NAME
      
$banner["h3"] = translate("Order by").": ".$sortRelevance.$sortName.$sortRating." | ".translate("Price").": ".$sortPriceAsc.", ".$sortPriceDesc;
?>

Cheers,
David.