rejetto forum

Software => HFS ~ HTTP File Server => HTML & templates => Topic started by: skb on February 22, 2015, 04:08:56 AM

Title: Help modifying (and understanding!) hfs.tpl sortlink macro? FIXED IN 2.3e
Post by: skb on February 22, 2015, 04:08:56 AM
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
Title: Re: Help modifying (and understanding!) hfs.tpl sortlink macro?
Post by: rejetto 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
Title: Re: Help modifying (and understanding!) hfs.tpl sortlink macro?
Post by: skb on February 24, 2015, 07:17:50 PM
FIXED in HFS version 2.3e  :)