Single Click Sorting

9 posts by 3 authors in: Forums > CMS Builder
Last Post: May 3, 2010   (RSS)

By mark99 - April 29, 2010 - edited: April 29, 2010

Here's a quick question.

I have my list of products (records) being output on the list viewer PHP page but what I'd really like to do is offer the ability to quickly order key fields in Ascending or Descending order. Most of my competitors do this in a simple way by offering a clickable title (i.e. "Name", "Price" etc.) and when you click that once it re-orders the list to the opposite of the default order. So if I click the "Price" heading then suddenly all the records order by lowest price first, click it again and it orders by most expensive first etc.

Since CMS Builder is really a clever MySQL interface then this should be possible but I can't find a simple solution and PHP isn't my strong point lol.

Re: [mark99] Single Click Sorting

By zip222 - April 29, 2010

You might want to consider using javascript/jquery for this...

here is one option:
http://tablesorter.com/docs/

Re: [Jason] Single Click Sorting

By mark99 - April 30, 2010 - edited: April 30, 2010

Yes that would work but for one big problem.

For some reason I found that CMS Builder didn't autmatically apply alphanumeric ordering to title field records so I was forced to set an orderBy in the "LOAD RECORDS" call at the top as follows:

'orderBy' => 'title ASC'

This of course causes me problems because it..

1) Screws up the output of _min and _max in search forms by always prioritising the title field ordering

2) Overides any orberBy I might try to force in a URL call.

How can I solve this so that my list output defaults to title ordering but allows me to change that in the URL?

I tried to set sorting to 'title ASC' in the admincp but it had no affect on the listing output (ED: I tried to put "dragSortOrder, title ASC" but no affect).

Re: [mark99] Single Click Sorting

By Jason - April 30, 2010

Hi,

Do you use "dragSortOrder" in the section editor, or have you removed that?

If you could attach the page you're working with, I can take a look at it for you.

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/

Re: [Jason] Single Click Sorting

By mark99 - April 30, 2010 - edited: April 30, 2010

If by "remove" you mean, have I tried to remove it from the 'Order By' box under 'Sorting' then the answer is yes but it just puts it back and says something about not being able to remove it while it is still a part of the listed fields for my section. Indeed given the description of 'dragSortOrder' I am concerned that removing it would prevent me being able to order my fields in the AdminCP for ease of use and it's not even clear if I could add it back.

I find dragSortOrder to be very irritating because given it's purpose it really should not be trying to dominate how the public display of information is handled. So what would you suggest?

I would prefer not to attach my private works here.

Re: [mark99] Single Click Sorting

By Jason - April 30, 2010

Hi,

You can get rid of dragSortOrder sorting by removing it from the "Listpage Fields" and "Sorting" sections of the section editor (note: remove it from both places before "Saving Changes")

Other than that, you can email me the file if you like to jason@interactivetools.com and I'll take a look at it.

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/

Re: [Jason] Single Click Sorting

By mark99 - May 2, 2010 - edited: May 2, 2010

Yes but does that mean I will no longer be able to change the order of fields in the admin section editor?

This is essential, otherwise my data input will be literally messed up and randomly all over the place.
If I take it out then there seems to be no clear way of adding it back as the field itself does not specify its details.

Re: [mark99] Single Click Sorting

By Jason - May 3, 2010

Hi,

dragSortOrder is just for sorting records. You can remove dragSortOrder and still be able to organize your fields however you wish.

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/