0
Well I’m starting the journey in a project, offered by my School, to gain experience in the area of programming, I got in the middle of it, and I’m having some problems performing simple tasks. So I’m trying to execute a method, which depends on data filled in the view, but I have no idea how to do such an act.
the Code a view:
{% for post in posts %}
<div class="ui card">
<div class="content">
<span class="right floated star">
{{ post['data'] }}
</span>
<div class="header">{{ post['titulo']|e }}</div>
<div class="description">
<p>{{ post['descricao']|e }}</p>
</div>
</div>
<div class="extra content">
<span class="left floated like" id="{{ post['id_post'] }}">
<i class="like icon"></i>
{{ post[''] }} Likes
//AVISO AQUI EM CIMA É O LOCAL ONDE DEVERIA SER PREECHIDO COM A QUANTIDADE DE CURTIDAS //
</span>
<div class="right floated author">
<img class="ui avatar image" src="{{ post['caminho']|e }}"> {{ "%s %s"|format(post['nome'], post['ultimo_nome']) }}
</div>
</div>
</div>
{% endfor %}
The method:
public function countCurtidas($idpost){
return ($this->db->query("SELECT COUNT(id_curtida) as curtidas FROM curtida WHERE id_post = $idpost")->row_array());
}
So to perform this precise method of id_post
provided from the view to then fill in with the amount of likes that this post has. Remembering that the view is a template TWIG and I’m using the CODEIGNITER.