[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date
][Minivend by thread
]
Re: Retrieving database field names.
****** message to minivend-users from Frank Miedreich <miedreich@acm.org> ******
>****** message to minivend-users from "Yossi Cohen" <yossi@prodigy.net>
>******
>
>Hi everybody,
>
>Just wondered whether any one bumped into trying to retrieve database field
>names using minivend tags. I am trying to display the products table in a
>web form for administration purposes and where the columns heading would be
>the field names.
>
>As usual I will be very glad to even get No as an answer. ;-)
>
>Yossi
>
I don't think there is a way to retireve the fieldnames via minivend tags.
You could cheat though (using perl):
tag export to temp file
open temp file for reading
read first line
close file
split by delimiter
the perl code:
my $delim = "\t";
open(DATA, '/the/path/to/the/database/file/products/temp.asc');
my @fieldnames = split /$delim/, <DATA>;
close DATA;
return '<TR><TH>' . join('</TH><TH>', @fieldnames) . '</TH></TR>';
as open is trapped by safe this would have to go into a sub into minivend.cfg.
otherwise you could safe untrap open and close in the minivend.cfg
the code is completely free of any error checking, $delim is your database
delimiter, tab by default, and if you return the list of filednames space
delimited you can use the output for a minivend [loop]
Things to think about:
Safe untrap open/close: Bad idea: allows lots of evil things
global sub: Better.
directly opening products.asc would be a bad thing (it could possibly
change while you are reading)
Frank
--
Frank Miedreich
Max-Planck-Institut fuer psychologische Forschung
-
To unsubscribe from the list, DO NOT REPLY to this message. Instead, send
email with 'UNSUBSCRIBE minivend-users' in the body to Majordomo@minivend.com.
Archive of past messages: http://www.minivend.com/minivend/minivend-list