dolibarr/htdocs/website/samples/page-sample-news.html
2024-09-06 20:28:06 +08:00

60 lines
3.2 KiB
HTML

<!-- Enter here your HTML content. Add a section with an id tag and tag contenteditable="true" if you want to use the inline editor for the content -->
<section id="div1" class="dolcontenteditable" style="text-align: center" contenteditable="true">
<br>
__(MyContainerTitle)__
<br><br>
</section>
<!-- Blog list -->
<section id="sectionnews" contenteditable="true" class="main section-50 section-md-50 section-md-bottom-50">
This is an example of a section to show the list of latest 5 articles (container with type "blogpost"), that contains the keyword "mykeyword"...<br>
<h2>Latest Blog posts</h2>
<div class="center">
<?php
$keyword = '';
$weblangs->loadLangs(array("main"));
$websitepage = new WebsitePage($db);
$fuser = new User($db);
$arrayofblogs = $websitepage->fetchAll($website->id, 'DESC', 'date_creation', 5, 0, array('type_container'=>'blogpost', 'keywords'=>$keyword));
if (is_numeric($arrayofblogs) && $arrayofblogs < 0)
{
print '<div class="error">'.$weblangs->trans($websitepage->error).'</div>';
}
elseif (is_array($arrayofblogs) && ! empty($arrayofblogs))
{
foreach($arrayofblogs as $blog)
{
print '<div class="row justify-content-sm-center row-40">';
print '<div class="container blog-box centpercent" style="padding: 20px; transition: .3s all ease;">';
print '<a href="'.$blog->pageurl.'.php">';
print '<div class="post-boxed-img-wrap"><img src="'.($blog->image ? 'viewimage.php?modulepart=medias&file='.$blog->image : 'medias/image/'.$website->ref.'/calendar.svg"').'" alt="" width="120"></div>';
print '<div class="post-boxed-caption">';
print '<div class="post-boxed-title font-weight-bold">'.$blog->title.'</div>';
print '<ul class="list-inline list-inline-dashed text-uppercase">';
print '<li>'.dol_print_date($blog->date_creation, 'daytext', 'tzserver', $weblangs).'</li>';
$fuser->fetch($blog->fk_user_creat);
print '<li><span>by<span> <span class="text-primary">'.($fuser->firstname?$fuser->firstname:$fuser->login).'</span></span></li>';
print '</ul>';
print '</div>';
//includeContainer($blog->pageurl);
print '<span class="nohover">'.$blog->description.'</span>';
print '</a>';
print '</div>';
print '</div>';
}
}
else
{
print '<div class="row justify-content-sm-center row-40">';
print '<div class="container blog-box centpercent" style="padding: 20px; transition: .3s all ease;">';
print $weblangs->trans("NoArticlesFoundForTheKeyword", $keyword);
print '</div>';
print '</div>';
}
?>
</div>
</section>