You are here:  » order by a to z

Support Forum



order by a to z

Submitted by wilkins on Mon, 2007-06-25 22:27 in

Hi

I dont know if this exists, at present there is a order by relevence and price, I would also like to order by A-Z, would this be posible.

Thanks

Brent

Submitted by support on Tue, 2007-06-26 05:25

Hello Brent,

Yes - that can be easily added. In search.php, make the following changes:

After the following EXISTING code:

$orderByDefault = array();
Add the following NEW code:
$orderByDefault["name"] = "name";

After the following EXISTING code:

$orderByFullText = array();
Add the following NEW code:
$orderByFullText["name"] = "name";

After the following EXISTING code:

$sortRelevance = ($sort=="relevance"?"<strong>".translate("Relevance")."</strong>":"<a href='".$sortHREF."relevance'>".translate("Relevance")."</a>");
Add the following NEW code:
$sortName = ", ".($sort=="name"?"<strong>".translate("Name")."</strong>":"<a href='".$sortHREF."name'>".translate("Name")."</a>");

Modify the following code:

$banner["h3"] = translate("Order by").": ".$sortRelevance.$sortRating." | ".translate("Price").": ".$sortPriceAsc.", ".$sortPriceDesc;
As follows:
$banner["h3"] = translate("Order by").": ".$sortRelevance.$sortName.$sortRating." | ".translate("Price").": ".$sortPriceAsc.", ".$sortPriceDesc;

This will add the "Name" sort option to the list of sort options, and you can of course change the legend to "A-Z" if you wish just by changing the text within the the calls to the translate() function. If you're unsure of where the changes need to go feel free to email me a copy of your existing search.php and i'll pop the changes in for you.

Cheers,
David.

Submitted by chrisst1 on Thu, 2007-08-30 11:15

Hi David

Is it possible to extend the above code to sort by either A-Z OR Z-A

Tasha

Submitted by support on Thu, 2007-08-30 11:22

Hi Tasha,

That's doable - here's a copy of the instructions above assuming no modifications made so far, which will add A-Z and Z-A to the sort options. You can of course change the text displayed for these in the code below where it says translate("A-Z") and translate("Z-A") - just replace with the require text.

$orderByDefault = array();
Add the following NEW code:
$orderByDefault["nameAZ"] = "name ASC";
$orderByDefault["nameZA"] = "name DESC";

After the following EXISTING code:

$orderByFullText = array();
Add the following NEW code:
$orderByFullText["nameAZ"] = "name ASC";
$orderByFullText["nameZA"] = "name DESC";

After the following EXISTING code:

$sortRelevance = ($sort=="relevance"?"<strong>".translate("Relevance")."</strong>":"<a href='".$sortHREF."relevance'>".translate("Relevance")."</a>");
Add the following NEW code:
$sortNameAZ = ", ".($sort=="nameAZ"?"<strong>".translate("A-Z")."</strong>":"<a href='".$sortHREF."nameAZ'>".translate("A-Z")."</a>");
$sortNameZA = ", ".($sort=="nameZA"?"<strong>".translate("Z-A")."</strong>":"<a href='".$sortHREF."nameZA'>".translate("Z-A")."</a>");

Modify the following code:

$banner["h3"] = translate("Order by").": ".$sortRelevance.$sortRating." | ".translate("Price").": ".$sortPriceAsc.", ".$sortPriceDesc;
As follows:
$banner["h3"] = translate("Order by").": ".$sortRelevance.$sortNameAZ.$sortNameZA.$sortRating." | ".translate("Price").": ".$sortPriceAsc.", ".$sortPriceDesc;

Hope this helps,
Cheers,
David.

Submitted by chrisst1 on Thu, 2007-08-30 11:35

That was quick, many thanks shall give it ago this afternoon.

Been given the job while boss on hols he also mentioned sorting category page A-Z on seperate pages, looked on forum but cannot find info he said was there.

Tasha

Submitted by support on Thu, 2007-08-30 11:50

Hi Tasha,

Might have been referring to this thread:

http://www.pricetapestry.com/node/266

Cheers,
David.

Submitted by chrisst1 on Thu, 2007-08-30 12:56

Yep that looks right

Thanks