I've got a customer request to sort images by rating, hits, and image create date. I'm using the highslide theme for all galleries. I'm pretty database and PHP savvy, but before I start this I wanted to get guidance from anyone else who has done or attempted this.
Sorry for not being more specific. The customer wants me to code a user selectable sort and unless I'm missing something, the custom sort you mention is an admin option, not user selectable. Do I have that right?
Yes, this is an admin selectable sort.
Please take a look at the printSearchForm() function in template-functions.php. You will note that it has a parameter $query_fields This parameter is used to supply the fields to be searched. Note, however, that it is subservient to the allowed search fields (set by the option) so that you can select only fields which are enabled by the admin option.
Just do you thing and pass the list of fields to the function. As always, we recommend looking at the functions guide to see what you can do with the existing functions.
Is the $sorttype variable used to identify a specific column in the database? For example, if we are sorting by date would the PHP value of $sorttype be "date" ? What is the syntax for referencing column names? Are they enclosed in doublequotes "date" or in single quotes 'date' or in tildes date?
When I use the actual database column name for $sorttype, it works the way I intended. For instance if I want to have the php code determine $sorttype for the images displayed in a gallery, I assign a value to $sorttype in the code as follows:
$sorttype="rating"; I then pass in $sorttype to the paramater list for printRating()