Re: [SMARTY] example not working...

From: Date: Tue, 10 Oct 2006 15:47:25 +0000
Subject: Re: [SMARTY] example not working...
References: 1 2  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-13500@lists.php.net to get a copy of this message
Thanks for the help, Ken. However, I now have a couple new questions. First: There is a th_attr attribute listed for html_table (link below). I cannot get it to work. I tried using a string and assigning an array in the php file to be passed to the template. Neither worked. Second: I also tried, on a whim, to use the caption attribute. It seems fairly simple, but again, it does not work. My line looks like this: {html_table loop=$tableData cols=2 caption="hello" table_attr='border="2"' tr_attr=$colors} For what it's worth, I am getting a bit frustrated with html_table as things do not seem to be working as advertised. I would either appreciate corrections to the documentation or more examples showing how things work - e.g. and example using *all* the attributes for whatever function it is. Note: I am aware this is open source and many work very hard and volunteer. I fully respect that. I am not trying to be mean, just trying to give some feedback from a new user's point of view. That is important if you want people to adopt your product. By the way - I do like Smarty so far...very cool indeed. Thank you much, Michael Kolakowski Ken Snyder wrote:
It appears that the documentation is incorrect. Using version 2.6.14, the cols parameter is only used as an integer. It has no functionality to pass in column names or do <th> at all. You might try a custom plugin from one of the plugin repositories. Ken From plugins/function.html_table.php $loop_count = count($loop); if (empty($params['rows'])) {
       /* no rows specified */
       $rows = ceil($loop_count/$cols);
} elseif (empty($params['cols'])) {
       if (!empty($params['rows'])) {
           /* no cols specified, but rows */
           $cols = ceil($loop_count/$rows);
       }
} Michael Kolakowski wrote:
Hi, I cannot seem to get the third table in this example to work: http://smarty.php.net/manual/en/language.function.html.table.php I am using the latest smarty and php5 on a Mac. The problem is the cols attribute. I typed it in exactly like the example and I get a divide by zero error. I also tried declaring an array, with the col names, in my php file. Then I tired using the array as such in my template file: {html_table loop=$tableData cols=$colNames tr_attr=$colors} At which point the table finally showed up, BUT there was only one column...and none of the column names were there. The alternating colors worked, however. Thanks, Michael Kolakowski


« previous php.smarty.general (#13500) next »