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

Simple variable assignment problem!!!

 
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 -> Smarty Development
View previous topic :: View next topic  
Author Message
furious5
Smarty Rookie


Joined: 06 Sep 2004
Posts: 16

PostPosted: Mon Nov 15, 2004 3:43 pm    Post subject: Simple variable assignment problem!!! Reply with quote

I was wondering if you guys can help me.

I'm currently building a table dynamically in a SMARTY template. I assign a variable $group_size to show the maximum number of people within a group this builds the number of table cells to be displayed.

I then loop through and build a list of players for an event in each group.

My problem is that if I only have 1 person in 1 group, then I get some empty table cells. If I have a group_size of 3

Code:

{section name=rows loop=$entrants}
      <tr class="{cycle values="leader_lightrow, leader_darkrow"}">
         <td class="groupno">{$entrants[rows].0.groupno}</td>
         <td class="tee_off">{$entrants[rows].0.tee_off_time|date_format:"%H:%M"}</td>
         <td class="start">{$entrants[rows].0.starthole}</td>
         {foreach item=player from=$entrants[rows].players}
         <td class="players">{$player}</td>
         {/foreach}
      </tr>
      {/section}


Anyone got any better ways to overcome this??


Last edited by furious5 on Wed May 05, 2010 10:38 pm; edited 1 time in total
Back to top
View user's profile Send private message
MisYu
Smarty Rookie


Joined: 12 Sep 2004
Posts: 16

PostPosted: Tue Nov 16, 2004 6:43 pm    Post subject: Reply with quote

Wouldn't that help?

{section name=rows loop=$entrants}
<tr class="{cycle values="leader_lightrow, leader_darkrow"}">
<td class="groupno">{$entrants[rows].0.groupno}</td>
<td class="tee_off">{$entrants[rows].0.tee_off_time|date_format:"%H:%M"}</td>
<td class="start">{$entrants[rows].0.starthole}</td>
<td class="players">
<table>
<tr>
{foreach item=player from=$entrants[rows].players}
<td class="players">
{$player}
</td>
{/foreach}
</tr>
</table>
</td>
</tr>
{/section}

Is that what you want?
Back to top
View user's profile Send private message Send e-mail
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Tue Nov 16, 2004 7:17 pm    Post subject: Reply with quote

You might look at http://smarty.php.net/html_table
Back to top
View user's profile Send private message Visit poster's website
furious5
Smarty Rookie


Joined: 06 Sep 2004
Posts: 16

PostPosted: Wed Nov 17, 2004 10:17 am    Post subject: Reply with quote

Thanks for the replies.

The problem is not solved as yet. Basically part of the problem is to do with the array structure I have, the players dimension of my array has an index which is sequentially numbered.

If I have only 1 entry for the array, I only get one table cell returned, if I have 2 entries then I have two table cells and so on. Because I am using alternating row colours the table looks totally flawed.

One I idea I had was to loop through the $group_size variable I set which will give me the maximum size of a group and build the cells this way to overcome the problem.

My problem now is that I cannot access the array as I need.

Here is what I'm trying to do, any help on this would be greatly appreciated:
Code:

{section name=rows loop=$entrants}
      &lt;tr class=&quot;{cycle values=&quot;leader_lightrow, leader_darkrow&quot;}&quot;&gt;
         &lt;td class=&quot;groupno&quot;&gt;{$entrants[rows].0.groupno}&lt;/td&gt;
         &lt;td class=&quot;tee_off&quot;&gt;{$entrants[rows].0.tee_off_time|date_format:&quot;%H:%M&quot;}&lt;/td&gt;
         &lt;td class=&quot;start&quot;&gt;{$entrants[rows].0.starthole}&lt;/td&gt;
         {section name=i loop=$group_size}
         &lt;td class=&quot;players&quot;&gt;{$entrants[rows].players.[i]}&lt;/td&gt;
         {/section}
      &lt;/tr&gt;
      {/section}


My problem is that this just causes SMARTY to bomb giving me the following error: syntax error: unrecognized tag: $entrants[rows].players.[i]

________
BMW Z9

Last edited by furious5 on Tue Feb 01, 2011 2:28 am; edited 2 times in total
Back to top
View user's profile Send private message
furious5
Smarty Rookie


Joined: 06 Sep 2004
Posts: 16

PostPosted: Wed Nov 17, 2004 10:19 am    Post subject: Reply with quote

Just realised my problem. Amended my final line to read: $entrants[rows].players[i]
________
Yamaha XV1900
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 -> Smarty Development 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