I cant quite get a hold of Twig really. I want to just simply display a function in a twig file but nothing is shown. My function:
public function ratings(){
$overall_vote_rows = $blog_vote_overall_rows;
$overall_vote_rate = $blog_vote_overall_rate;
$overall_vote_dec_rate = $blog_vote_overall_dec_rate;
$ip_vote_rate = $blog_vote_ip_rate;
echo '<input type="hidden" name="blog_content_id" id="blog_content_id" value="1"/>';
$stars = '';
echo '<div id="ajax_vote">';
for ($i = 1; $i <= floor($overall_vote_rate); $i++) {
$stars .= '<div class="star" id="' . $i . '"></div>';
}
//THE OVERALL RATING (THE OPAQUE STARS)
echo '<div class="r"><div class="rating">' . $stars . '</div>';
//THE TRANSPARENT STARS (OPAQUE STARS WILL COVER AS MANY STARS AS THE RATING REPRESENTS)
echo '<div class="transparent">
<div class="star" id="1"></div>
<div class="star" id="2"></div>
<div class="star" id="3"></div>
<div class="star" id="4"></div>
<div class="star" id="5"></div>
<div class="votes">(' . $blog_vote_overall_dec_rate . '/5, ' . $overall_vote_rows . ' ' . ($overall_vote_rows > 1 ? ' votes' : ' vote') . ') ' . ($blog_vote_ip_rate > 0 ? '<strong>You rated this: <span style="color:#39C;">' . $blog_vote_ip_rate . '</span></strong>' : '') . '</div>
</div>
</div>';
echo '</div>';
$this->twig->display('boat/boat_list.twig',$data);
Now when i try to display the function it wont show up. i guess i completly missunderstand the principle as such since even trough reading in the documentation im to simple minded to get it.
{{ratings}}
shouldnt this do the trick?
Thanks in advance. Id love to just use the php code since i cant figure how to properly translate it into the twig syntax.