I have a view of audio nodes, sorted by track number. It sorts tracks like this:

1
10
11
2
3
4
etc...

I tried appending zeroes to the single-digit tracks but after i pressed submit the result was the same, the zeroes didnt take.

Comments

sgriffin’s picture

Any luck on this?

drewish’s picture

Version: 5.x-1.0 » 5.x-2.x-dev
Status: Active » Needs review

here's a patch that should do it. you'll need to remove the existing sorts, clear the views cache (it's on the views tool tab), and re-add the sorts.

sgriffin’s picture

I believe you forgot to attach your patch! But thanks in advance!

drewish’s picture

StatusFileSize
new1.28 KB

right you are. and i can't even blame it on previewing now...

sgriffin’s picture

It looks like its working.. but you must NOT make the field "Sortable", and use the default sort otherwise it sorts the same way.

Cool thanks, I think I can live with that.

sgriffin’s picture

StatusFileSize
new2.68 KB

Hmm I did patch it, but it looks like it is not working after all. I see the patch was applied in views_audio.inc but the sort is the same.
On my working views, the audio nodes were luckily created in order.

Perhaps the patch didn't fully work? I have attached my inc.

sgriffin’s picture

StatusFileSize
new4.94 KB
drewish’s picture

it applied. as you pointed out though the table sorting won't work with this...

sgriffin’s picture

ok, then how would you use the patch?

Or sort correctly with a table view?

Could the view module be altered itself?
This does seem to be an issue going back to 2005, I've found when searching. I could alter the views module, since I only use views for sorting by track.

drewish’s picture

scroll down to the bottom of the view edit form, you find a section for "sorts", try using that for sorting.

sgriffin’s picture

True, the metatag fields are not available there however.
I guess I could copy the track field into another field, and perhaps that would sort correctly.
Or be very careful and sort by node title which pulls in the filename... or that might only see !filename.
damn damn

Thanks for your help. I appreciated it.

drewish’s picture

the metatag fields are not available there however.

what do you mean? "Audio: Tag *" are the meta data sort criteria...

sgriffin’s picture

Under sort criteria, it shows a drop down list of cck fields, node created time, tax term, but...

I think I found something weird. The first option blank, but in the code.....!!

But as you can see the label is BLANK!

I wonder where this is going to take me.

sgriffin’s picture

option value="audio_metadata_track.value" selected="selected"> "/option

Whoops tags stripped.

sgriffin’s picture

That was it! Sorting by track on a table view is a big secret, due to the fact the label is blank! Crikey.

drewish’s picture

StatusFileSize
new1.28 KB

here's a patch that gets the table sort working too.

sgriffin’s picture

Hmmm that killed it, and gave my working view a mysql query error.

No offense, but I'm not going to touch anything again. :)

drewish’s picture

Status: Needs review » Needs work

sgriffin, i understand your reluctance to continue testing this once you've got it working but i hope you'll reconsider. i've spent several hours on this this to help improve the module for everyone. i'd ask you to consider your time testing this patch as "payment" for my efforts. i'd like to get this committed knowing that it works correctly.

so, could you tell me what the error message said?

sgriffin’s picture

Ok ok certainly. I did succeed in the file rollback. So I will update you momentarily.

Hunk #1 succeeded at 130 with fuzz 1 (offset 7 lines).
Hunk #2 FAILED at 165.
1 out of 2 hunks FAILED -- saving rejects to file views_audio.inc.rej

I tried the patch against the original and the previously patched file.
So I think that could be the reason.

sgriffin’s picture

Checking the module I have 5.1.0 installed.
Installed and patching against a fresh dev.

drewish’s picture

thanks, i really do appreciate your help.

as you noticed, that patch was against the clean version of the file.

i've got a suspicion about the cause. looking at http://drupal.org/node/99565 there's a note that when using a sort_handler:

Without this handler it will simply be table.field. Please note that a query_handler may be necessary as some databases want ORDER BY clauses to also appear in the SELECT, which means a $query->add_field may need to be performed, and that cannot be performed by this handler.

sgriffin’s picture

Yes, it works very good, and with the dev version the option labels are now appearing under sort criteria.
And the player is customizable via views.. Great.
Something I am doing also is replacing the output for the button.. to use swfobject. I guess this should be done with swftools filter, but I don't think it natively supports the button player.

This text is replaced by the Flash movie.
var so = new SWFObject("$url", "mymovie", "17", "17", "8", "#333333"); so.addParam("FlashVars", "$flashvars"); so.addParam("wmode", "transparent"); so.write("$flashvars");

You've helped alot of people. Good work.

sgriffin’s picture

Perhaps I did not understand.. Using the default sort option for the track field did NOT work .. but sort criteria did work.

drewish’s picture

Status: Needs work » Needs review
StatusFileSize
new2.37 KB

okay, i think i've got it worked out. this should work for both table sorting and sort criteria.

sgriffin’s picture

You nailed it. Its working perfectly!

drewish’s picture

Status: Needs review » Fixed

Great, committed to HEAD and DRUPAL-5. Thanks again for your help testing this.

sgriffin’s picture

Version: 5.x-2.x-dev » 5.x-1.x-dev

I have noticed an issue.. though I have no idea if its related.. When editing the metadata of a track the last one OR two characters of the input field never makes it to the db.
Also when coming from audio import. title and album.

5.x-1.x-dev

Going to install the head instead.

drewish’s picture

sgriffin’s picture

theres something wonky in there.. I reinstalled 5.x.10 and the issue is gone..
The issue exists with the head and dev versions.

sgriffin’s picture

Ah so the dev and head must use v2 from then on..

You rock!

Anonymous’s picture

Status: Fixed » Closed (fixed)
Fr0s7’s picture

Version: 5.x-1.x-dev » 6.x-1.x-dev
Component: Miscellaneous » Views support
Category: feature » bug
Status: Closed (fixed) » Active

Re-opening this for 6.x Views 2:

Sorting by Audio meta-data: Track (ascending) is happening alphabetically instead of numerically. For example, a list of 24 tracks returns this:

1
10
11
12
13
14
15
16
17
18
19
2
20
21
22
23
24
3
4
5
6
7
8
9

drewish’s picture

Status: Active » Closed (fixed)

this is really part of #273082: Add views2 support since it's a matter up upgrading the existing code.