rejetto forum
Software => HFS ~ HTTP File Server => HTML & templates => Topic started by: Foggy on December 09, 2007, 01:24:41 PM
-
Can we change ?rev to a urlvar that needs a value because I am trying to create a sort button that will automatically reverse the list each time it is pressed but it is impossible with the way that the if macro says something is true, the ?rev urlvar is always empty when called by {{urlvar|rev}} and therefor always false.
I tried assigning a value to ?rev but then the list wasnt reversed.
a couple different of if macros I tried are.
{{if | {{match | {{urlvar | sort}} | n}} | {{if | {{match | {{urlvar | rev}} | 1}} | ?rev&sort=n | ?rev=1&sort=n}} | ?rev=1&sort=n}}
and
{{if | {{urlvar | sort}} | {{if | {{urlvar | rev}} | ?sort=n | ?rev&sort=n}} | ?sort=n}}
I think that the second one is the simpler and more lightweight of the two and the only thing that is stopping it from working is that ?rev is always reported as empty creating a false statement when it is true.
Note: I just did a test before I post and I found that when the urlvar is empty (ie ?test) and you try to match it with something, it returns true. Which explains why my first if macro doesn't work.
Note: I have something that works with the current problems im facing but needs a little of refining still.
<a href="{{if | {{urlvar | sort}} | {{if | {{match | {{urlvar | sort}} | n}} | {{if | {{urlvar | rev}} | ?rev&sort=n | ?rev=1&sort=n}} | ?rev=1&sort=n}} | ?rev=1&sort=n}}">Name</a>
-
it's a good idea.
from next build the default tpl will use this
{{get|url|sort=s|rev={{not|{{?rev}} }} }}
quite readable, isn't it?
-
nouvelle syntaxe pour 'rev' ?
?sort=xx&rev=xx&..
{{?sort}} est-il l'équivalent de la pseudo macro {{is define|sort}} dans ce cas
{{?rev}} permettra de savoir si rev se trouve dans l'url
de même que {{?recursive}} ??
en effet {{urlvar|sort}} permet de connaitre la valeur utilisé pour sort=xx
mais {{urlvar|rev}} et {{urlvar|reverse}} sont inutilisables d'où mon idée d'introduire
{{is def | parmetre_url}} return true or false
par contre je trouve assez illogique qu'un test retourne une chaine vide à la place de la valeur false et une chaine non vide pour la valeur true
exemple {{if |%user%| then |else}} ne devrait fonctionner que si %user% est true ou false, sinon on devrait utiliser en toute rigeur
{{ if | {{ not | {{ equal | %user% | }} }} | then | else }}
quelques mises au point sont à faire comme,
procedure trueIf(cond:boolean);
begin if cond then result:='true' else result:='false' end;
function isFalse(s:string):boolean; inline;
begin result:=stringExists(s, ['false','FALSE']) end;
function isTrue(s:string):boolean; inline;
begin result:=stringExists(s, ['true','TRUE']) end;
-
{{get|url|sort=s|rev={{not|{{?rev}} }} }}
It confuses me, care to explain how it works.
and its alot better then what i had.
-
{{?sort}} est-il l'équivalent de la pseudo macro {{is define|sort}} dans ce cas
no, it's a shortcut to {{urlvar}}
de même que {{?recursive}} ??
from next build, when a parameter like recursive has no value, {{urlvar}} will return 1 .... and so will {{?}}
? remembers the same ? used for url parameters
par contre je trouve assez illogique qu'un test retourne une chaine vide à la place de la valeur false et une chaine non vide pour la valeur true
1. it is handy
2. it's the same in javascript, and people who make templates often needs to know javascript
3. it's the same in php, that is always web oriented
exemple {{if |%user%| then |else}} ne devrait fonctionner que si %user% est true ou false, sinon on devrait utiliser en toute rigeur
{{ if | {{ not | {{ equal | %user% | }} }} | then | else }}
what's this suggestion for? complicate things?
-
{{get|url|sort=s|rev={{not|{{?rev}} }} }}
It confuses me, care to explain how it works.
and its alot better then what i had.
?rev is {{urlvar|rev}}
when it's 1, the {{not}} returns an empty string, so you have rev= (nothing) which is interpreted as "not rev"
when the rev is 0 or not set, the {{not}} will return '1', so you have rev=1
-
from next build, when a parameter like recursive has no value, {{urlvar}} will return 1 .... and so will {{?}}
? remembers the same ? used for url parameters
je pense que le plus simple serait d'avoir une macro {{urldef|recursive}}
qui donnerait une chaine vide '' si recursive n'est pas dans l'url et 'recursive' s'il s'y trouve
...
<br>
Liste des paramètres URL : {{urldef|recursive}},{{urldef|rev}},{{urldef|sort}}, ...
<br>
...
{{ get | url | sort=s |{{ if | {{ urldef | rev }}| | rev}} }} permet d'activer ou désactiver & rev par un seul click
<th><a href="{{get|url|sort=n|{{if not|{{=|{{urlvar|sort}}|n}}| |{{if{{urldef|rev}}| |rev /if}} /if}} /get}}">Filename</a>
<a href="{{get|url|sort=e|{{if not|{{=|{{urlvar|sort}}|e}}| |{{if{{urldef|rev}}| |rev /if}} /if}} /get}}">.ext</a>
<th><a href="{{get|url|sort=s|{{if not|{{=|{{urlvar|sort}}|s}}| |{{if{{urldef|rev}}| |rev /if}} /if}} /get}}">Filesize</a>
<th><a href="{{get|url|sort=t|{{if not|{{=|{{urlvar|sort}}|t}}| |{{if{{urldef|rev}}| |rev /if}} /if}} /get}}">Filetime</a>
<th><a href="{{get|url|sort=d|{{if not|{{=|{{urlvar|sort}}|d}}| |{{if{{urldef|rev}}| |rev /if}} /if}} /get}}">Hits</a>
-
the solution i proposed (and that is already implemented in next build) is clearly much more simple/easy: it's shorter, and there is no new macro to learn.
-
<th><a href="{{get|url|sort=n|{{if not|{{=|{{urlvar|sort}}|n}}| |rev={{not|{{?rev}} }} /if}} }}">Filename</a>
<a href="{{get|url|sort=e|{{if not|{{=|{{urlvar|sort}}|e}}| |rev={{not|{{?rev}} }} /if}} }}">.ext</a>
<th><a href="{{get|url|sort=s|{{if not|{{=|{{urlvar|sort}}|s}}| |rev={{not|{{?rev}} }} /if}} }}">Filesize</a>
<th><a href="{{get|url|sort=t|{{if not|{{=|{{urlvar|sort}}|t}}| |rev={{not|{{?rev}} }} /if}} }}">Filetime</a>
<th><a href="{{get|url|sort=d|{{if not|{{=|{{urlvar|sort}}|d}}| |rev={{not|{{?rev}} }} /if}} }}">Hits</a>
To try it is to adopt, this piece of template will delight it more of one
-
macros are nice... but hfs knows when building the page by which field and in wich order the list will be sorted.
Why not offer directly some values as status:
%statsort% (possible values:"fname,ext,size,time,hits,com") and
%statorder% (values:"up,down" or 'asc,desc' or 'norev,rev')
instead of evaluating 5 lines of nested macros?
-
Hello bacter, do not you leave on your web page the possibility of choosing the order of sorting according to the choice of the user?
but hfs knows when building the page by which field and in wich order the list will be sorted.
Yes by user with url line
instead of evaluating 5 lines of nested macros?
A droplet in an ocean ;D ;D
-
i want to use this new way for the next beta
<table id='files' cellpadding='5'>
{.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|Filename.}{.^sortlink|e|.ext.}
<th>{.^sortlink|s|Filesize.}
<th>{.^sortlink|t|Filetime.}
<th>{.^sortlink|d|Hits.}
%list%
</table>
-
So long as it works, then I will use it, it is a little more elegant than the old method.