par
VisualDev » 24 oct. 2011, 12:40
$articleData = null;
if (isset($_GET['id']) && is_numeric($_GET['id']))
{
$id = intval($_GET['id']); // On choisis un article selon le paramètre $_GET
$getNews = dbquery("SELECT * FROM site_news WHERE id = '" . $id . "' LIMIT 1");
if (mysql_num_rows($getNews) > 0)
{
$articleData = mysql_fetch_assoc($getNews);
}
}
else
{
$getNews = dbquery("SELECT * FROM site_news ORDER BY timestamp DESC LIMIT 1");
if (mysql_num_rows($getNews) > 0)
{
$articleData = mysql_fetch_assoc($getNews);
}
}
$tpl->Init(); // Initiation de la page
$tpl->AddGeneric('head-init');
$tpl->AddIncludeFile(new IncludeFile('text/css', WWW . '/style.css', 'stylesheet'));
$tpl->WriteIncludeFiles();
$tpl->AddGeneric('head-bottom');
$tpl->AddGeneric('barre'); // Menu + Login
$newslist = new Template('comp-newlist'); // Liste des articles
$article = new Template('comp-newsarticle');
$newslist->SetParam('mode', 'recent');
if ($articleData != null)
{
$newslist->SetParam('name', $articleData['title']);
$newslist->SetParam('id_article', $articleData['id']);
ça suffira ?
J'ai encore le code de mon TPL
/*for ($i = 1; $i <= $value; $i++){
if ($i != $id_article) {
echo'<a href="' . WWW . '/article.php?id=' . $ID_db . '">' . $Titre . '</a> ';
}
else { echo"<li class='new'>" . $name . "</li>"; }
}*/
if ($mode == 'recent')
{
for ($i = 0; $i < 6; $i++)
{
$sectionName = '';
$sectionCutoffMax = 0;
$sectionCutoffMin = 0;
switch ($i)
{
case 0:
$sectionName = 'Aujourd\'hui';
$sectionCutoffMax = time();
$sectionCutoffMin = time() - 86400;
break;
case 1:
$sectionName = 'Hier';
$sectionCutoffMax = time() - 86400;
$sectionCutoffMin = time() - 172800;
break;
case 2:
$sectionName = 'Ce week-end';
$sectionCutoffMax = time() - 172800;
$sectionCutoffMin = time() - 604800;
break;
case 3:
$sectionName = 'La semaine dernière';
$sectionCutoffMax = time() - 604800;
$sectionCutoffMin = time() - 1209600;
break;
case 4:
$sectionName = 'Ce mois-ci';
$sectionCutoffMax = time() - 1209600;
$sectionCutoffMin = time() - 2592000;
break;
case 5:
$sectionName = 'Le mois dernièr';
$sectionCutoffMax = time() - 2592000;
$sectionCutoffMin = time() - 5184000;
break;
}
$q = "SELECT * FROM site_news WHERE timestamp >= " . $sectionCutoffMin . " AND timestamp <= " . $sectionCutoffMax . " ORDER BY timestamp DESC";
$getArticles = dbquery($q);
if (mysql_num_rows($getArticles) > 0)
{
echo '<h2>' . $sectionName . '</h2>
<ul>';
while ($a = mysql_fetch_assoc($getArticles))
{
echo '<li class="new">
<a href="%www%/article.php?id=' . $a['id'] . '" class="article-' . $a['id'] . '">' . clean(decode($a['title'])) . ' »</a>
</li>';
}
echo '</ul>';
}
}
}
[php]$articleData = null;
if (isset($_GET['id']) && is_numeric($_GET['id']))
{
$id = intval($_GET['id']); // On choisis un article selon le paramètre $_GET
$getNews = dbquery("SELECT * FROM site_news WHERE id = '" . $id . "' LIMIT 1");
if (mysql_num_rows($getNews) > 0)
{
$articleData = mysql_fetch_assoc($getNews);
}
}
else
{
$getNews = dbquery("SELECT * FROM site_news ORDER BY timestamp DESC LIMIT 1");
if (mysql_num_rows($getNews) > 0)
{
$articleData = mysql_fetch_assoc($getNews);
}
}
$tpl->Init(); // Initiation de la page
$tpl->AddGeneric('head-init');
$tpl->AddIncludeFile(new IncludeFile('text/css', WWW . '/style.css', 'stylesheet'));
$tpl->WriteIncludeFiles();
$tpl->AddGeneric('head-bottom');
$tpl->AddGeneric('barre'); // Menu + Login
$newslist = new Template('comp-newlist'); // Liste des articles
$article = new Template('comp-newsarticle');
$newslist->SetParam('mode', 'recent');
if ($articleData != null)
{
$newslist->SetParam('name', $articleData['title']);
$newslist->SetParam('id_article', $articleData['id']);[/php]
ça suffira ?
J'ai encore le code de mon TPL
[php]/*for ($i = 1; $i <= $value; $i++){
if ($i != $id_article) {
echo'<a href="' . WWW . '/article.php?id=' . $ID_db . '">' . $Titre . '</a> ';
}
else { echo"<li class='new'>" . $name . "</li>"; }
}*/
if ($mode == 'recent')
{
for ($i = 0; $i < 6; $i++)
{
$sectionName = '';
$sectionCutoffMax = 0;
$sectionCutoffMin = 0;
switch ($i)
{
case 0:
$sectionName = 'Aujourd\'hui';
$sectionCutoffMax = time();
$sectionCutoffMin = time() - 86400;
break;
case 1:
$sectionName = 'Hier';
$sectionCutoffMax = time() - 86400;
$sectionCutoffMin = time() - 172800;
break;
case 2:
$sectionName = 'Ce week-end';
$sectionCutoffMax = time() - 172800;
$sectionCutoffMin = time() - 604800;
break;
case 3:
$sectionName = 'La semaine dernière';
$sectionCutoffMax = time() - 604800;
$sectionCutoffMin = time() - 1209600;
break;
case 4:
$sectionName = 'Ce mois-ci';
$sectionCutoffMax = time() - 1209600;
$sectionCutoffMin = time() - 2592000;
break;
case 5:
$sectionName = 'Le mois dernièr';
$sectionCutoffMax = time() - 2592000;
$sectionCutoffMin = time() - 5184000;
break;
}
$q = "SELECT * FROM site_news WHERE timestamp >= " . $sectionCutoffMin . " AND timestamp <= " . $sectionCutoffMax . " ORDER BY timestamp DESC";
$getArticles = dbquery($q);
if (mysql_num_rows($getArticles) > 0)
{
echo '<h2>' . $sectionName . '</h2>
<ul>';
while ($a = mysql_fetch_assoc($getArticles))
{
echo '<li class="new">
<a href="%www%/article.php?id=' . $a['id'] . '" class="article-' . $a['id'] . '">' . clean(decode($a['title'])) . ' »</a>
</li>';
}
echo '</ul>';
}
}
}[/php]