Sorting Bug
2 posts by 2 authors in: Forums > CMS Builder
Last Post: April 15, 2010 (RSS)
By mark99 - April 15, 2010 - edited: April 15, 2010
I currently have a list of products that I want to display as a list from 0-A-Z based on the title field (product name), so for example I would have.
India
Victor
Zulu
However when I adjust 'Sorting' inside the admincp to "dragSortOrder ASC, title" this returns my viewer output as this.
Zulu
India
Victor
If I change it to "dragSortOrder DESC, title" then my viewer output goes to this.
Victor
India
Zulu
For some reason the alphabetic/alphanumeric ordering of my 'title' (product name) field is getting it completely wrong, India should be at the TOP (ASC) or BOTTOM (DESC) but never the middle of those three as both V and Z come later in the alphabet. What is going wrong, how can I order my list alphanumerically?
Also is it possible to use SEO Search Urls to order my price field by ASC or DESC values or can SEO Search URL's only be used for linear field matching?
India
Victor
Zulu
However when I adjust 'Sorting' inside the admincp to "dragSortOrder ASC, title" this returns my viewer output as this.
Zulu
India
Victor
If I change it to "dragSortOrder DESC, title" then my viewer output goes to this.
Victor
India
Zulu
For some reason the alphabetic/alphanumeric ordering of my 'title' (product name) field is getting it completely wrong, India should be at the TOP (ASC) or BOTTOM (DESC) but never the middle of those three as both V and Z come later in the alphabet. What is going wrong, how can I order my list alphanumerically?
Also is it possible to use SEO Search Urls to order my price field by ASC or DESC values or can SEO Search URL's only be used for linear field matching?
Re: [mark99] Sorting Bug
By Jason - April 15, 2010
Hi,
dragSortOrder is a field in the section that stores the order that the products appear in the section editor. If you rearrange them on the page, you'll see your results change. If you want to to just sort on name however, remove dragSortOrder from the line so it just reads: "title ASC" or "title DESC".
You can control the sort order on the viewer in a couple of ways.
1) you can control it from the URL by setting the createdBy variable to any field name (example: www.mysite.com/results.php?orderBy=title)
2) you can add an orderby command to the mysql string.
Example:
Hope this helps.
dragSortOrder is a field in the section that stores the order that the products appear in the section editor. If you rearrange them on the page, you'll see your results change. If you want to to just sort on name however, remove dragSortOrder from the line so it just reads: "title ASC" or "title DESC".
You can control the sort order on the viewer in a couple of ways.
1) you can control it from the URL by setting the createdBy variable to any field name (example: www.mysite.com/results.php?orderBy=title)
2) you can add an orderby command to the mysql string.
Example:
<?php
list($productRecords,$productMetaData)=getRecords(array(
'tableName' => 'products',
'orderBy'=> 'title ASC',
));
?>
Hope this helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/