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

using {function} via {include}

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


Joined: 09 Nov 2009
Posts: 8

PostPosted: Mon Nov 09, 2009 6:09 pm    Post subject: using {function} via {include} Reply with quote

Using this setup:

templates/table.tpl:
Code:
{function name=mytable}
  <table>{foreach $data as $row}
    <tr>{foreach $row as $column}
      <td>{$column}</td>
    {/foreach}</tr>
  {/foreach}<table>
{/function}

templates/index.tpl:
Code:
{include file="table.tpl"}
{mytable data=$data}

index.php:
Code:
<?php
require_once('Smarty-3.0b1/libs/Smarty.class.php');
$data=array(array(1,2), array(4,5), array(6,7));
$smarty = new Smarty;
$smarty->assign('data', $data);
$smarty->display('index.tpl');
?>

this happens: The table data is displayed only when index.php is called for the first time. The second and all following calls, nothing is shown.

When I delete the cached templates, table data is displayed again, but again only once.

Updating to last SVN (r3321) didn't help.
Back to top
View user's profile Send private message
bdrewery
Smarty n00b


Joined: 09 Nov 2009
Posts: 1

PostPosted: Mon Nov 09, 2009 6:30 pm    Post subject: Reply with quote

I have the same problem with caching / first load / 2nd load not showing anything. I however am not using functions in the included templates.
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Mon Nov 09, 2009 8:55 pm    Post subject: Reply with quote

The fix is in the SVN now
Back to top
View user's profile Send private message
thm
Smarty Rookie


Joined: 09 Nov 2009
Posts: 8

PostPosted: Mon Nov 09, 2009 9:37 pm    Post subject: Reply with quote

U.Tews wrote:
The fix is in the SVN now


Revision 3322 works, but 3323 shows the problem again.

As expected, setting force_compile = true also helps.
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Mon Nov 09, 2009 9:50 pm    Post subject: Reply with quote

could you retry please.
Back to top
View user's profile Send private message
thm
Smarty Rookie


Joined: 09 Nov 2009
Posts: 8

PostPosted: Mon Nov 09, 2009 10:02 pm    Post subject: Reply with quote

U.Tews wrote:
could you retry please.


Revision 3324 works, thx!
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 3 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