|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
LadyArch3r Smarty n00b
Joined: 15 Apr 2013 Posts: 2
|
Posted: Mon Apr 15, 2013 12:27 pm Post subject: Smarty Array |
|
|
Code: | $get_s = get('class="col1">', '</td>', $content);
$get_t = get('class="col2">', '</td>', $content);
$get_o = get('class="col3">', '</td>', $content);
$get_p = get('class="col9">', '</td>', $content);
$get_av = get('class="col10">', '</td>', $content);
$get_c = (count($get_s) - 1)/3;
//Superlig Puan Durumu
echo'
<table width="400px" border="1" cellpadding="0" cellspacing="0" style="border:1px dotted #ccc;">
<tr style="background-color:#000; color:#fff; font-weight:bold;">
<td style="width:20px;">Sıra</td>
<td style="width:220px;">Takım Adı</td>
<td style="width:20px;">O</td>
<td style="width:20px;">P</td>
</tr>
';
for ($i=0; $i<=$get_c; $i++) {
echo '
<tr>
<td><b>'.$get_s[$i].'</b></td>
<td>'.strip_tags($get_t[$i]).'</td>
<td>'.$get_o[$i].'</td>
<td>'.$get_p[$i].'</td>
</tr>
';
}
echo '</table>'; |
output
smarty use
Code: | $spor_var = array(
'gets' => get('class="col1">', '</td>', $content),
'gett' => get('class="col2">', '</td>', $content),
'geto' => get('class="col3">', '</td>', $content),
'getp' => get('class="col9">', '</td>', $content),
'getc' => (count($get_s) - 1)/3
);
$smarty->assign('item',$spor_var); |
problem here
foreach, for ...
tpl file not show |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Mon Apr 15, 2013 2:01 pm Post subject: |
|
|
How does your template file look like? |
|
Back to top |
|
LadyArch3r Smarty n00b
Joined: 15 Apr 2013 Posts: 2
|
Posted: Mon Apr 15, 2013 3:11 pm Post subject: |
|
|
U.Tews wrote: | How does your template file look like? |
I can not do
Code: | <ul>
{foreach from=$items key=myId item=i}
<li><a href="item.php?id={$myId}">{$i.no}: {$i.label}</li>
{/foreach}
</ul> |
like |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Mon Apr 15, 2013 4:30 pm Post subject: |
|
|
Your {foreach from=$items item=i} will return in $i the content of PHP variables $gets, $gett, $geto, $getp and $getc. All but the last are itself an array. But they contain no index 'no' or 'label' as in your last posted template code.
Your template code does not at all match your posted original PHP code.
So you screwed everything up.
I can't guess what you wanted to do. |
|
Back to top |
|
|
|
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
|