Author Topic: Help modifying (and understanding!) hfs.tpl sortlink macro? FIXED IN 2.3e  (Read 1440 times)

0 Members and 1 Guest are viewing this topic.

Offline skb

  • Occasional poster
  • *
  • Posts: 48
    • View Profile
Note: version 2.3e corrects the bug mentioned below. Now sorting columns work as expected.  :D


On the standard hfs.tpl, the default sort link goes through four states when you click it repeatedly. I'd like to change the code so it just toggles two states, forward and reverse sort of the given column.

E.g I have "Name" selected in HFS>Menu>Other Options>Default Sorting; so if I don't click anything, files are alphabetical.

When I repeatedly click the "Size" button, the search URL changes as follows:
?sort=s (that is, sorted by size, smallest first)
?rev=1(reversed, but no field specifier, so in my case, sorted Z-A by name)
?rev=1&sort=s(sorted by size, biggest first)
(fourth click gives no sort code, so in my case, sorted A-Z by name)
?sort=s ( cycle repeats... )

I'd like it to just toggle the order of the selected field, e.g. when size is clicked repeatedly, alternate between these two states:
?sort=s (that is, sorted by size, smallest first)
?rev=1&sort=s(sorted by size, biggest first)
?sort=s ( and repeat... )

But to me the existing sortlink macro is hard going! Here it is:
Code: [Select]
            {.set|sortlink| {:<a href="{.trim|
                    {.get|url|sort=$1| {.if| {.{.?sort.} = $1.} |  rev={.not|{.?rev.} .} /if.} /get.}
                /trim.}">{.!$2.}{.if| {.{.?sort.} = $1.} | &{.if|{.?rev.}|u|d.}arr;.}</a>:} .}
            <th>{.^sortlink|n|Name.}{.^sortlink|e|.extension.}
            <th>{.^sortlink|s|Size.}
            <th>{.^sortlink|t|Timestamp.}
            <th>{.^sortlink|d|Hits.}

Can someone explain how to modify the sortlink macro so that that it skips those other two parts of the cycle?

Thanks
« Last Edit: April 01, 2015, 10:29:01 PM by skb »

Offline rejetto

  • Administrator
  • Tireless poster
  • *
  • Posts: 12953
    • View Profile
Re: Help modifying (and understanding!) hfs.tpl sortlink macro?
« Reply #1 on: February 24, 2015, 07:04:25 PM »
that's just because of a bug
http://www.rejetto.com/forum/programmers-corner/last-beta-sources/msg1059938/#msg1059938

otherwise it would work as you expected

Offline skb

  • Occasional poster
  • *
  • Posts: 48
    • View Profile
Re: Help modifying (and understanding!) hfs.tpl sortlink macro?
« Reply #2 on: February 24, 2015, 07:17:50 PM »
FIXED in HFS version 2.3e  :)
« Last Edit: April 01, 2015, 10:29:49 PM by skb »