rejetto forum
May 25, 2012, 01:55:39 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: This forum is free, you do NOT need to register to post. But you may.
PROBLEMS? QUESTIONS? CLICK HERE!
Fill the survey!
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Change ?rev  (Read 2835 times)
0 Members and 2 Guests are viewing this topic.
Foggy
Insane poster
*****
Offline Offline

Australia Australia

Posts: 806


View Profile
« on: December 09, 2007, 07:24:41 AM »

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>
« Last Edit: December 09, 2007, 07:42:43 AM by Foggy » Logged
rejetto
Administrator
Insane programmer
*
Offline Offline

Italy Italy

Posts: 11829


View Profile
« Reply #1 on: December 09, 2007, 01:30:58 PM »

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?
Logged
Mars
Operator
Insane poster
*****
Offline Offline

France France

Posts: 1481



View Profile WWW
« Reply #2 on: December 09, 2007, 04:15:07 PM »

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;
 
Logged
Foggy
Insane poster
*****
Offline Offline

Australia Australia

Posts: 806


View Profile
« Reply #3 on: December 09, 2007, 06:00:18 PM »

{{get|url|sort=s|rev={{not|{{?rev}} }} }}

It confuses me, care to explain how it works.

and its alot better then what i had.
Logged
rejetto
Administrator
Insane programmer
*
Offline Offline

Italy Italy

Posts: 11829


View Profile
« Reply #4 on: December 10, 2007, 05:20:18 PM »

{{?sort}}  est-il l'équivalent de la pseudo macro {{is define|sort}} dans ce cas

no, it's a shortcut to {{urlvar}}

Quote
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

Quote
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

Quote
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?
Logged
rejetto
Administrator
Insane programmer
*
Offline Offline

Italy Italy

Posts: 11829


View Profile
« Reply #5 on: December 10, 2007, 05:22:12 PM »

{{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
Logged
rejetto forum
« Reply #5 on: December 10, 2007, 05:22:12 PM »

Do you like this software? Consider even $2
 Logged
Mars
Operator
Insane poster
*****
Offline Offline

France France

Posts: 1481



View Profile WWW
« Reply #6 on: December 10, 2007, 05:45:47 PM »

 
Quote
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

Quote
   <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>
« Last Edit: December 10, 2007, 06:20:33 PM by mars » Logged
rejetto
Administrator
Insane programmer
*
Offline Offline

Italy Italy

Posts: 11829


View Profile
« Reply #7 on: December 10, 2007, 07:46:12 PM »

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.
Logged
Mars
Operator
Insane poster
*****
Offline Offline

France France

Posts: 1481



View Profile WWW
« Reply #8 on: December 11, 2007, 04:00:57 AM »

Quote
<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
Logged
bacter
Operator
Insane poster
*****
Offline Offline

Spain Spain

Posts: 679


View Profile
« Reply #9 on: December 11, 2007, 09:23:21 AM »

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?
Logged

your computer has no brain - use your own !
Mars
Operator
Insane poster
*****
Offline Offline

France France

Posts: 1481



View Profile WWW
« Reply #10 on: December 11, 2007, 01:09:19 PM »

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?
Quote
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

Quote
instead of evaluating 5 lines of nested macros?

A droplet in an ocean Grin Grin

« Last Edit: December 11, 2007, 04:19:35 PM by mars » Logged
rejetto
Administrator
Insane programmer
*
Offline Offline

Italy Italy

Posts: 11829


View Profile
« Reply #11 on: September 01, 2008, 07:22:10 PM »

i want to use this new way for the next beta
Code:
    <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>
Logged
TSG
Operator
Insane poster
*****
Offline Offline

Australia Australia

Posts: 1919



View Profile WWW
« Reply #12 on: September 02, 2008, 04:27:31 AM »

So long as it works, then I will use it, it is a little more elegant than the old method.
Logged

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!


Google visited last this page May 10, 2012, 02:55:36 AM
anything