Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.
Smarty Array

 
Post new topic   Reply to topic    Smarty Forum Index -> Smarty 3
View previous topic :: View next topic  
Author Message
LadyArch3r
Smarty n00b


Joined: 15 Apr 2013
Posts: 2

PostPosted: Mon Apr 15, 2013 12:27 pm    Post subject: Smarty Array Reply with quote

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
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Mon Apr 15, 2013 2:01 pm    Post subject: Reply with quote

How does your template file look like?
Back to top
View user's profile Send private message
LadyArch3r
Smarty n00b


Joined: 15 Apr 2013
Posts: 2

PostPosted: Mon Apr 15, 2013 3:11 pm    Post subject: Reply with quote

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
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Mon Apr 15, 2013 4:30 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    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