AutoDirector forum

The AutoDirector support and advice forum

order by cheapest for one site only?

Post Reply

Page: 1

Author Post
Member
Registered: Apr 2008
Posts: 67
Hi, I have multiple sites, but the client wants one of the sites to be ordered by cheapest first by default.

I saw the other thread about editing carlist.js, but this will effect all sites.
Is there a CSS or URL method I can use to reverse the order for one of the sites?
Administrator
Registered: Apr 2008
Posts: 324
Hi. Yes, changing the order in carlist,js will affect every site. One possible option is to use a little JavaScript to detect which site the showroom is running on. There are several ways to achieve that, but perhaps the easiest is to check the domain using:

if (window.location="domain.com") { do this order } else { do the default order }

Of course, you could always buy another copy of AutoDirector too!
_______________
AutoDirector administrator
Member
Registered: Apr 2008
Posts: 67
Considering the fabulous price, that would be easier! :D
Member
Registered: Apr 2008
Posts: 67
I've broken it :oops:

if (window.location="mydealer.co.uk/brandname") { function SortCars(a, b, asc) } else { function SortCars(b, a, asc) }



Is there an obvious flaw in my non existent java skills? - I get a syntax error.
Administrator
Registered: Apr 2008
Posts: 324
OK, perhaps I should have included a little more detail. I'd suggest something like this in carlist.js after line 61...

// check domain
if (window.location.host=="www.dealerdomain.com") {

// sort by lowest first
sortTypes[st++] = { name: "price, lowest first", sort: function(a, b) { return SortCars(a.price, b.price, 1); } };
sortTypes[st++] = { name: "price, highest first", sort: function(a, b) { return SortCars(a.price, b.price, -1); } };

}
else {

// sort by highest first
sortTypes[st++] = { name: "price, highest first", sort: function(a, b) { return SortCars(a.price, b.price, -1); } };
sortTypes[st++] = { name: "price, lowest first", sort: function(a, b) { return SortCars(a.price, b.price, 1); } };

}

// do all other sorting types
sortTypes[st++] = { name: "make/model, A to Z", sort: function(a, b) { return SortCars(a.model, b.model, 1); } };
// etc...


If the domain matches, the price sort is by lowest first. You could set up quite complex rules to handle differing customer requirements. The sortType[st++] = {...} lines can be re-arranged as you like.

Hope that helps! :D
_______________
AutoDirector administrator
Member
Registered: Apr 2008
Posts: 67
Brill! - im getting the hang of java a little bit now.. I have used window.location.pathname instead as my dealers are all on one domain, but in sub directories eg domain.com/ford ..../vauxhall

Thanks!

Post Reply

Page: 1