Linux SRV-16 6.18.44-paas #1 SMP PREEMPT_DYNAMIC Thu Aug 13 10:08:12 UTC 2026 x86_64
/
srv
/
data
/
web
/
vhosts
/
www.taxi-78.com
/
htdocs
/
pages
/
/srv/data/web/vhosts/www.taxi-78.com/htdocs/pages/news.php
<?php //start_block('title','keywords','description') start_block('global news','',''); ?> <div id="news"> <h1>Actualités</h1> <?php $newsPerPage = 10; $stmt=$db_client->prepare("SELECT COUNT(*) as nbNews FROM news WHERE id_company=?"); // on prépare notre requête $stmt->execute(array($conf_id_company)); $rows=$stmt->fetch(); $nbNews = $rows->nbNews; $nbPages = ceil($nbNews/$newsPerPage); $temp = explode("-",$slug); $numPage = (isset($temp[1])) ? $temp[1] : 1; if(isset($numPage) && !empty($numPage) && $numPage>0 && $numPage<=$nbPages) $currentPage = $numPage; else $currentPage = 1; $prevPage = ($currentPage>1)?$currentPage - 1:1; $nextPage = ($currentPage<$nbPages)?$currentPage + 1:$nbPages; $beginAt = ($currentPage-1)*$newsPerPage; $stmt=$db_client->prepare(" SELECT n.id as id, title, image, author, n.email as email, content,n.created_at as created_at, update_at,COUNT(CASE WHEN c.state=1 THEN 1 ELSE NULL END) as nbComments FROM news n LEFT JOIN news_comment AS c ON c.news = n.id WHERE n.id_company = $conf_id_company GROUP BY n.id ORDER BY update_at DESC LIMIT :beginAt,:newsPerPage"); // on prépare notre requête $stmt->bindParam(':beginAt', $beginAt, PDO::PARAM_INT); $stmt->bindParam(':newsPerPage', $newsPerPage, PDO::PARAM_INT); $stmt->execute(); $rows=$stmt->fetchAll(); ?> <?php foreach ($rows as $row): ?> <a href="<?=$routes['news-single']."-".$row->id?>-<?=urlencode($row->title)?>" class="thumbnail"> <?php if (!is_null($row->image)): ?> <div class="row"> <div class="col-sm-3"> <img loading="lazy" src="<?=$row->image?>" alt="<?=$row->image?>" class="img-responsive thumbnail"> </div> <div class="col-sm-9"> <?php endif ?> <h2><?=$row->title?></h2> <p class="text-muted">Ajouté le <?=date("d/m/Y",strtotime($row->update_at))?></p> <?php if($row->nbComments>0): ?> <p><span class="fa fa-comments fa-fw"></span> <?=$row->nbComments?> commentaires</p> <?php endif ?> <?php if (!is_null($row->image)): ?> </div> </div> <?php endif ?> <?php $text = strip_tags($row->content);//Suppression des balises $text = substr($text,0,300);//Longueur du texte $position_espace = strrpos($text, " ");//Position du dernier espace echo substr($text, 0, $position_espace)."... <i class='read-more'>Lire la suite</i>";//Affichage jusqu'au dernier espace + ajout ... ?> </a> <?php endforeach ?> <?php if($nbPages>1): ?> <ul class="pagination"> <li <?=($currentPage==1)?"class='disabled'":""?>><a href="<?=$routes['news']."-".($prevPage)?>">«</a></li> <?php for ($i=1; $i<=$nbPages ; $i++) { echo"<li ".(($i==$currentPage)?"class='active'":"").">"; echo "<a href='$routes[news]-$i'>$i</a>"; echo"</li>"; } ?> <li <?=($currentPage==$nbPages)?"class='disabled'":""?>><a href="<?=$routes['news']."-".($nextPage)?>">»</a></li> </ul> <?php endif ?> </div> <?php end_block(); ?>