Beta of updated table function
| From: | Peter Bowyer | Date: | Fri, 08 Mar 2002 21:52:45 +0000 |
| Subject: | Beta of updated table function | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-2987@lists.php.net to get a copy of this message | ||
Hi,
This is a beta version, and you can find the code at http://www.mapledesign.co.uk/coding/function.table.phps
I haven't got as far as updating the changelog yet, but the major new features are:
1. It will work with associative arrays
2. You can now build down columns instead of across rows. This requires an extra attribute: arrange='horizontal' or arrange='vertical' depending which way you want it.
Building a vertical table may give funny results sometimes. For instance, if you have an array of 9 items and have specified the table to have 4 columns, it would give 3 columns with 3 entries and one with nothing in. I felt this was most odd, and therefore if the function encounters this kind of situation it doesn't add the blank column. I'm open to suggestions as to whether this is the best behaviour or not - if you want to try it the other way change the following section:
//$loop = array_pad($loop, $_rows * $cols, $pad_val);
// Above line shouldn't be needed with the following
$table->setAutoFill($pad_val);
to
$loop = array_pad($loop, $_rows * $cols, $pad_val);
// Above line shouldn't be needed with the following
//$table->setAutoFill($pad_val);
I am asking for people's thoughts and opinions on sections of the code or ideas, and these comments are usually TYPED IN CAPITALS so they are easier to find. Obviously, if you have a comment to make about some other part of the code then I'd like to hear it :-)
Thanks,
Peter.
--
Maple Design - http://www.mapledesign.co.uk