Unverified Commit 7e8d4ad4 authored by Sebastian Castro's avatar Sebastian Castro
Browse files

Display multiple news, and improve news rendering

parent 13a6276f
......@@ -10,15 +10,14 @@ use Doctrine\ODM\MongoDB\Repository\DocumentRepository;
final class NewsRepository extends DocumentRepository
{
public function findLastPublishedNews(\DateTime $lastNewsletterSentAt): ?News
public function findLastPublishedNews(\DateTime $lastNewsletterSentAt)
{
return $this->createQueryBuilder()
->field('status')->equals(NewsStatus::PUBLISHED)
->sort('publicationDate', 'desc')
->field('publicationDate')->lte(new \DateTime())
->field('publicationDate')->gte($lastNewsletterSentAt)
->limit(1)
->getQuery()
->getSingleResult();
->execute();
}
}
......@@ -187,7 +187,12 @@ class MailService
if ('newsletter' === $mailType && $element instanceof User) {
$lastNews = $this->newsRepository->findLastPublishedNews($element->getLastNewsletterSentAt());
$string = preg_replace('/({{((?:\s)+)?news((?:\s)+)?}})/i', $lastNews ? $lastNews->getContent() : '', $string);
$content = '';
foreach ($lastNews as $news) {
$content .= $this->twig->render('emails/news.html.twig',
['news' => $news, 'config' => $this->config]);
}
$string = preg_replace('/({{((?:\s)+)?news((?:\s)+)?}})/i', $content, $string);
}
$homeUrl = $this->generateRoute('gogo_homepage');
......
......@@ -2,24 +2,24 @@
height: 100%;
padding: 30px 45px">
<div class="header" style="background-color : {{ config.getDefaultColor('contentBackgroundColor') }};
max-width: 700px;
max-width: 700px;
color: {{ config.textColor }};
margin: 0 auto;
border-radius: 5px;
font-weight: normal;
overflow: hidden;
text-align: center;
font-family: Arial, sans-serif;
line-height: 26px;
font-size: 15px;">
<div style="text-align:center;
padding: 10px;
border-radius: 5px 5px 0 0;
border-bottom: 1px solid #eaeaea;
background-color: {{ config.getDefaultColor('headerColor') }};">
<a href="{{ homeUrl }}">
{% if config.logo and config.logo.imageUrl %}
<img src="{{ config.logo.imageUrl }}" alt="{{ config.appName }}" title="{{ config.appName }}"
style="max-height: 100px;
style="max-height: 100px;
color: white;
font-family: sans-serif;
max-width: 100%;" />
......
<div style="margin-bottom: 30px;">
<h2 style="font-weight: bold;
font-size: 20px;
color: {{ config.primaryColor }}">
{{ news.title|raw }}
</h2>
<div>
{{ news.content|raw }}
</div>
</div>
<table style="width:100%">
{% for element in elements|slice(0,19) %}
{% for element in elements|slice(0,9) %}
<tr style="">
<td style="text-align: left;
......@@ -58,6 +58,6 @@
</tr>
{% endfor %}
</table>
{% if elements|length > 20 %}
<p style="margin-top: 20px;font-weight: bold;">... Et {{ elements|length - 20 }} autres à découvrir sur le site !</p>
{% if elements|length > 10 %}
<p style="margin-top: 20px;font-weight: bold;text-align: center;">... Et {{ elements|length - 10 }} autres à découvrir sur le site !</p>
{% endif %}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment