[pmwiki-users] Wikiform - empty fields, numeric type, page names

John Rankin john.rankin at affinity.co.nz
Tue Dec 13 16:10:29 CST 2005


On Wednesday, 14 December 2005 10:37 AM, Patrick R. Michaud <pmichaud at pobox.com> wrote:
>On Wed, Dec 14, 2005 at 10:28:47AM +1300, John Rankin wrote:
>> On Tuesday, 13 December 2005 11:27 PM, Andreas Mühlhausen
><mail at andreas-muehlhausen.de> wrote:
>> >Hi John,
>> >
>> >>>2) Is it possible to define a numeric field type, because I want to use 
>> >>>a numeric ordering in the (:wikilist:)?
>> >>
>> >>This can be added. To make the sort work, the form administrator will need 
>> >>to specify a length and the data will be automatically zero filled.
>> >>  
>> >>
>> >I think a solution with zerofilled values is not so good, because I have 
>> >values like i.e. 300 kilometres and it doesn't look quiet good if the 
>> >list displays them as '0300 km'. This is why I asked for
>> >numeric values.
>
>I'm coming at this late in the discussion (and don't know all of the
>details), but a different approach might be for the form administrator 
>to specify which fields are numeric, and use numeric comparisons 
>for sorting those fields instead of zero padding and using string 
>comparisons.  This also solves problems with negative versus
>positive values.

At the moment the script uses the CreateOrderFunction from
the PITS recipe, as a black box. I don't know how this works
or how to modify it to detect that one of the sort fields in
numeric and then use a numeric compare... So from where I sit
continuing to use string compare has the advantage that I can
make it work, with minimal effort.

I agree that numeric compare is a better way to do it. Any
hints on how to teach CreateOrderFunction about numeric
field values would be warmly welcomed.

>
>In PHP, a value can be converted from string to numeric by simply
>adding zero:
>
>    $a = "123"      # $a is a string '123'
>    $a += 0;        # $a is now a numeric 123
>
>So, if there's just some mechanism to specify that a given field
>is numeric (or to be compared numerically), that could be
>simpler.
>
>Pm
>


-- 
JR
--
John Rankin






More information about the pmwiki-users mailing list