title: Smarty 3 tpl: how to execute php plugin function that calls a smarty variable into the .tpl file?
body: <p>inside .tpl:</p>
  
  <pre><code>{assign var="datasheet" value=$product-&gt;reference|escape:'htmlall':'UTF-8'}
  ... ...
  {testsk}
  </code></pre>
  
  <p>function.testsk.php:</p>
  
  <pre><code>&lt;?php
  function smarty_function_testsk(){
  $ch = curl_init ("http://www.domain.com/path/to/".$smarty-&gt;get_template_vars('datasheet')."/name.html");
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  $page = curl_exec($ch);
  
  preg_match("/\s&lt;div id=\"divname\"&gt;(.*)&lt;\/div&gt;/siU", $page, $matches);
      foreach ($matches as &amp;$match) {
      $match = $match;
  }
  echo '&lt;table&gt;';
      echo $matches[1];
  echo '&lt;/table&gt;';
  }
  ?&gt;
  </code></pre>
  
  <p>obviously it doesn't work but with a given known variable function is good and tested
  i also tried to allow php tag into smarty class, it allows but i'm not able to access smarty variable.</p>
  
  <p>IT WORKS:</p>
  
  <pre><code>{php}
          $ch = curl_init ("http://www.domain.com/path/to/3345674/name.html");
          curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
          $page = curl_exec($ch);
  
          preg_match("/\s&lt;div id=\"divname\"&gt;(.*)&lt;\/div&gt;/siU", $page, $matches);
          foreach ($matches as &amp;$match) {
          $match = $match;
         }
          echo '&lt;table&gt;';
          echo $matches[1];
          echo '&lt;/table&gt;';
         {/php}
  </code></pre>
  
  <p>IT DOESN'T WORK:</p>
  
  <pre><code>{assign var="datasheet" value=$product-&gt;reference|escape:'htmlall':'UTF-8'}
             {php}
              $v1 = $this-&gt;get_template_vars('datasheet');
              $ch = curl_init ("http://www.domain.com/path/to/".$v1."/name.html");
              curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
              $page = curl_exec($ch);
  
              preg_match("/\s&lt;div id=\"divname\"&gt;(.*)&lt;\/div&gt;/siU", $page, $matches);
              foreach ($matches as &amp;$match) {
              $match = $match;
             }
              echo '&lt;table&gt;';
              echo $matches[1];
              echo '&lt;/table&gt;';
             {/php}
  </code></pre>
  
  <p>ERROR:</p>
  
  <pre><code>Fatal error: Using $this when not in object context in /var/www/vhosts/domain.com/httpdocs/folder/tools/smarty/plugins/block.php.php(23) : eval()'d code on line 2
  </code></pre>