-4
Basically the code loops through the database for posts, but it will only post if the scheduled date is less or equal to the current date. He searches the bank for all posts and lists, but those that are scheduled, he will not show. And when there are no scheduled posts or there is nothing in the bank, it says there are no posts.
There are two elses. Hence the question: There is how to use only one?
I tried several ways and I can’t. One is for when there is nothing in the bank, the other for when there are no scheduled posts. One He does not recognize the other. I would like one He only.
<div class="container">
<% var valor = "No posts!"; %>
<% if(noticias.length > 0) { %>
<% for(var i = 0; i < noticias.length; i++) { %>
<% if(noticias[i].publicacao_agendada <= moment(new Date()).format('YYYY-MM-DD[T]H:mm')) { %>
<div class="row">
<div class="col-md-12">
<div class="noticia_wrapper">
<%= noticias[i].publicacao_agendada %>
<span class="noticia_autor"><%=noticias[i].autor%></span>
<a href="noticia?id_noticia=<%= noticias[i].id_noticia %>" class="noticia_titulo"><%=noticias[i].titulo%></a>
<span class="noticia_data"><%= moment(noticias[i].data_noticia).format(data) %></span>
<br />
<p class="noticia_resumo">
<%=noticias[i].noticia%>
</p>
</div>
</div>
</div>
<% } else { %>
<h1><%= valor %></h1>
<% } %>
<% } %>
<% } else { %>
<h1><%= valor %></h1>
<% } %>
</div>
For ease of understanding, I, @Leocaracciolo, put something simpler
if(noticias.length > 0) {
for(var i = 0; i < noticias.length; i++) {
if(noticias[i].publicacao_agendada <= moment(new Date()).format('YYYY-MM-DD[T]H:mm')) {
} else {
}
}
} else {
}
Why so many tags? After all, your question is with PHP, Javascript, Java, C# and Node.JS?
– Valdeir Psr
That’s definitely not php.....
– rray
The
if
internal seems to be wrong, because would say that has not posts in each one that does not meet the condition? I think should seek to know what the word didactic means, it does not fit in this context.– Maniero