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

Bug in section, I think ..

 
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 -> Bugs
View previous topic :: View next topic  
Author Message
garfield_fr
Smarty n00b


Joined: 16 Nov 2003
Posts: 3

PostPosted: Sun Nov 16, 2003 9:03 pm    Post subject: Bug in section, I think .. Reply with quote

I think it's a bug: Look this template file and php file :

the template file (TestCarteSmarty.tpl):
Code:

{* Smarty *}
<HTML>
<HEAD>
</HEAD>
<BODY bgcolor="#FFFF80" alink="#000000" vlink="#000000" link="#000000" text="#000000">
<table border=1>
{section name="ligne" loop=$carte start=1}
   <TR>
   {section name="col" loop=$carte[ligne] start=1}
      <TD>{$carte[ligne][col]}</TD>
   {/section}
   </TR>
{/section}
</table>
</body>
</html>

The php file (TestCarteSmarty.php):
Code:

<?php
require('Smarty.class.php');
$smarty = new Smarty;
$smarty->template_dir = 'templates/';
$smarty->compile_dir = 'templates_c/';
$smarty->config_dir = 'configs/';
$smarty->cache_dir = 'cache/';
$smarty->debugging = true;

for($i=1;$i<11;$i++){
   for($j=1;$j<11;$j++){
      $carte[$i][$j]="\$i=$i,\$j=$j";
   }
}
$smarty->assign('carte',$carte);
$smarty->display('TestCarteSmarty.tpl');
?>

The script work ...but the table show at the end have only 9x9 cells. The original array $carte have 10x10 cells !!
I think there is a bug here ! I use Smarty 2.6.0rc2
Back to top
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Sun Nov 16, 2003 9:08 pm    Post subject: Reply with quote

to make them work with section your arrays have to start with key 0. this is regardless of the "start=1".
Back to top
View user's profile Send private message Send e-mail Visit poster's website
garfield_fr
Smarty n00b


Joined: 16 Nov 2003
Posts: 3

PostPosted: Sun Nov 16, 2003 9:41 pm    Post subject: Reply with quote

I try with array $carte start at index 0 on both dimension ans it work but ...
how I do if I want my array $carte start at 1 and not 0 on both dimension ? (i say 1 but it's possible to start at another value, but not 0)
maybe i need to use another function ?
Back to top
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Sun Nov 16, 2003 10:06 pm    Post subject: Reply with quote

you can use {foreach} instead.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
garfield_fr
Smarty n00b


Joined: 16 Nov 2003
Posts: 3

PostPosted: Sun Nov 16, 2003 11:24 pm    Post subject: Reply with quote

thanks !! foreach work fine !!!
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 -> Bugs 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