title: access to var from template in php before compile
body: <p>I want in template file can limit count of result, something like this :</p>
  
  <p>file.tpl</p>
  
  <pre><code>{$box_count = 10}
  
  {foreach $box}
  .
  .
  .
  {/foreach}
  </code></pre>
  
  <p>how can i handle and get this variables in php to limit result in database ?</p>
  
  <p>example :</p>
  
  <pre><code>&lt;?php
  $smarty = new Smarty;
  
  
  $count = ... //HOW CAN GET ?
  
  $data = array();
  $q = mysql_query( "SELECT * FROM `users` LIMIT 0,$count" );
  while( $r = mysql_fetch_array( $q ) )
  {
      $data[] = $r;
  }
  $smarty-&gt;assign( 'box' , $data );
  
  $smarty-&gt;dipslay( 'file.tpl' );
  ?&gt;
  </code></pre>
  
  <p><strong>note</strong> :
  because this var just defined in tpl file, in <code>getTemplateVars()</code> not exists .</p>
  
  <p>thanks</p>