Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Fill HTML-tables vertically with Smarty

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
Aar
Smarty Rookie


Joined: 19 Jul 2011
Posts: 12

PostPosted: Tue May 03, 2016 5:06 pm    Post subject: Fill HTML-tables vertically with Smarty Reply with quote

I have this table, and i have a question about it.
Code:

<table>
                            <tbody><tr>
                              <th>&nbsp;</th>
                              <th>mo</th>
                              <th>tu</th>
                              <th>we</th>
                              <th>th</th>
                              <th>fr</th>
                              <th>sa</th>
                              <th>su</th>
                            </tr>
                            <tr>
                              <td>min. temp</td>
                              <td>10</td>
                              <td>9</td>
                              <td>8</td>
                              <td>8</td>
                              <td>12</td>
                              <td>11</td>
                              <td>13</td>
                            </tr>
                            <tr>
                              <td>max. temp<br></td>
                              <td>18</td>
                              <td>17</td>
                              <td>15</td>
                              <td>16</td>
                              <td>18</td>
                              <td>17</td>
                              <td>19</td>
                            </tr>
                            <tr>
                              <td>weather</td>
                              <td>sunny</td>
                              <td>rain</td>
                              <td>sunny<br></td>
                              <td>cloudy</td>
                              <td>clear view</td>
                              <td>rain</td>
                              <td>cloudy</td>
                            </tr>
                          </tbody></table>


Now i'm curious how can i fill this table vertically with data. This is a weather-forecast table.

My array is:
Code:

[0] => Array
        (
            [time] => 1462226400
            [summary] => Lichte regen gedurende de ochtend.
            [icon] => rain
            [sunriseTime] => 1462248380
            [sunsetTime] => 1462302536
             .....
        )

    [1] => Array
        (
            [time] => 1462312800
            [summary] => Licht bewolkt gedurende de avond.
            [icon] => partly-cloudy-day
            [sunriseTime] => 1462334669
            [sunsetTime] => 1462389037
            .......
        )

    [2] => Array
        (
            [time] => 1462399200
            [summary] => Licht bewolkt gedurende de nacht.
            [icon] => partly-cloudy-night
            [sunriseTime] => 1462420961
            [sunsetTime] => 1462475538
            ...........
        )


Anyone an idea how i can solve this in Smarty?
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Tue May 03, 2016 5:35 pm    Post subject: Reply with quote

http://lmgtfy.com/?q=php+array+transpose
Back to top
View user's profile Send private message
Aar
Smarty Rookie


Joined: 19 Jul 2011
Posts: 12

PostPosted: Tue May 03, 2016 6:34 pm    Post subject: Reply with quote

Thanks.... but how can i implement this in Smarty?
Back to top
View user's profile Send private message
elpmis
Smarty Elite


Joined: 07 Jun 2007
Posts: 321

PostPosted: Tue May 03, 2016 8:28 pm    Post subject: Reply with quote

Try this

https://gist.github.com/edulan/1136654

It should be not too difficult to create a Smarty plugin with this sources - look here

http://www.smarty.net/docs/en/plugins.functions.tpl
Back to top
View user's profile Send private message
Aar
Smarty Rookie


Joined: 19 Jul 2011
Posts: 12

PostPosted: Tue May 03, 2016 9:24 pm    Post subject: Reply with quote

elpmis wrote:
Try this

https://gist.github.com/edulan/1136654

It should be not too difficult to create a Smarty plugin with this sources - look here

http://www.smarty.net/docs/en/plugins.functions.tpl

I tried it, but it gives a:
Fatal error: Call-time pass-by-reference has been removed

By removing the ampersand (&) the function doesn't works anymore. How can i make this work in PHP 5.5? On PHP 5.3 en lower, this works perfectly.
What now?
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Tue May 03, 2016 9:49 pm    Post subject: Reply with quote

Aar wrote:
Thanks.... but how can i implement this in Smarty?

You don't need to implement it in Smarty.
You need to implement it in PHP.
And only pass to Smarty the data prepared for display.
Back to top
View user's profile Send private message
Aar
Smarty Rookie


Joined: 19 Jul 2011
Posts: 12

PostPosted: Tue May 03, 2016 10:08 pm    Post subject: Reply with quote

AnrDaemon wrote:
Aar wrote:
Thanks.... but how can i implement this in Smarty?

You don't need to implement it in Smarty.
You need to implement it in PHP.
And only pass to Smarty the data prepared for display.

Thanks, i have figured this out, but the function is not working on the recent PHP version, because the ampersand. What now?
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Wed May 04, 2016 12:51 am    Post subject: Reply with quote

What function?…
Back to top
View user's profile Send private message
Aar
Smarty Rookie


Joined: 19 Jul 2011
Posts: 12

PostPosted: Wed May 04, 2016 6:33 am    Post subject: Reply with quote

AnrDaemon wrote:
What function?…

On the Github page.
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Wed May 04, 2016 6:18 pm    Post subject: Reply with quote

Then you failed to understand my answer.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP