title: Calling PHP Class Public Function Inside Smarty Template
body: <p>Can someone help me out here.</p>
  
  <p>How can i Call a PHP class public function inside a Smarty template file for example.</p>
  
  <p>I have 2 Functions inside the Movie Class</p>
  
  <pre><code>GetAllMovies(); // Gets all Movies
  </code></pre>
  
  <p>and </p>
  
  <pre><code>GetMovie($movie_id); // Gets movie by movie id
  </code></pre>
  
  <p>Now i am calling the <code>GetAllMovies();</code> and assigning it to the template</p>
  
  <pre><code>&lt;?php
    include 'movie.class.php';
    $movie = new Movie();
  
    $movies = $movie-&gt;GetAllMovies();
    $smarty-&gt;assign('movies',$movies);
  &lt;?
  </code></pre>
  
  <p>Now inside the template file i've got a <code>foreach</code> statement for the movies.</p>
  
  <pre><code>{foreach from=$movies key=key item=mov}
    // Access Movie ID, Title And Images 
  {/foreach}
  </code></pre>
  
  <p>Now what i want to do is to call <code>GetMovie($movie_id);</code> inside this <code>foreach</code> statement for example do something like this.</p>
  
  <p>Assign Movie class to Smarty Template.</p>
  
  <pre><code>$smarty-&gt;assign('movie',$movie);
  </code></pre>
  
  <p>Then use <code>$movie</code> to call the function for example</p>
  
  <pre><code>{foreach from=$movies key=key item=mov}
    {assign var=movie_info value=$movie::GetMovie($mov.id)}
    {$movie_info.rating} 
  {/foreach}
  </code></pre>
  
  <p>Could someone please point me in the right direction.</p>