Well, I have the following public function
:
/**
* Mostrar notícias
*
* @param string $featured - Define se será noticia de destaque ou padrão que mostrará
*
* @param string $date - Define o tempo em que mostrará as notícias recentes (ex: notícias recentes dentro de 7 dias)
*
* @param string $limit - Define o total de notícias que será mostrada por vez dentro da função
*/
public function newsShow($featured = 'No', $date = 7, $limit) {
$DB = new Database();
$Translate = new Translate();
$M = new Modulos();
$stm = $DB->readDB('news', 'WHERE Featured = "'.$featured.'" AND Date BETWEEN CURRENT_DATE()-'.$date.' AND CURRENT_DATE() ORDER BY Date DESC LIMIT '.$limit);
if (!$stm) {
echo '';
} else {
foreach ($stm as $key) {
// Envia as informações do banco de dados para as gets \
$this->SetID($key["ID"]);
$this->SetTitle($key["Title"]);
$this->SetSubTitle($key["SubTitle"]);
$this->SetCategory($key["Category"]);
$this->SetMessage($key["Message"]);
$this->SetFeatured($key["Featured"]);
$this->SetDate($key["Date"]);
// Define a tradução dos termos achados no banco de dados \
$title = json_decode($this->GetTitle(), true);
$subtitle = json_decode($this->GetSubTitle(), true);
$title_name = $title[U_LANG].PHP_EOL;
$subtitle_name = $subtitle[U_LANG].PHP_EOL;
$url = $M->tirarAcentos($Translate->set('href')['news'].$this->GetID().'-'.$title_name, true);
// Envia as informações do banco de dados para as gets \
$this->SetURL($url);
$this->SetTitle($title_name);
$this->SetSubTitle($subtitle_name);
}
}
}
So that's fine, so I call it out of class:
<?php echo $News->newsShow('Yes', 7, '0,1'); ?>
But what I want is to do a check out of the class to see if it has a news to be shown, getting more or less like this:
<?php if (função) { echo $News->newsShow('Yes', 7, '0,1'); } else { echo null; } ?>
But that's where it is, I do not know how to do it, because I need to show a div within that IF
, so look:
<?php if (funcao) { echo $News->newsShow('Yes', 7, '0,1');
echo '<div class="ak-block-title">
<a href="'.$News->GetURL().'" class="ak-title-link">
<div class="ak-layer">
<span class="ak-title"><?php '.$News->GetTitle().'</span>
<br><span class="ak-subtitle"><?php '.$News->GetSubTitle().'</span> <span class="ak-banner-more">+</span><br>
</div>
</a>
</div>'; } else { echo null; } ?>
Well this is what I want, but I do not know what to put in the IF
function to do this, please help!