Single Click Sorting

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

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: [mark99] Single Click Sorting

By Jason - April 29, 2010

Hi,

We can definitely do this, and it only takes a little bit of PHP.

This code creates a single link. Use this for each of your column headers that you would want to sort by.
<a href="*YOURPAGE*.php?orderBy=<?php echo (@$_REQUEST['orderBy']!="*FIELD*")? "*FIELD*" : "*FIELD* DESC" ?>">*FIELD LABEL*</a>

In this code, replace *YOURPAGE* with the name of the php page you're working with, *FIELD* with the database field you're wanting to sort on and *FIELD LABEL* with the name of the column. So, for example, if I wanted to sort by a products record number, it would look like this:

<a href="productsList.php?orderBy=<?php echo (@$_REQUEST['orderBy']!="num")? "num" : "num DESC" ?>">Record Number</a>

Give that a try and let me know if it works for you. If it doesn't, maybe attach the page you're working with and I'll 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

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/