Skip to content

Commit a006d20

Browse files
authored
Merge pull request #1036 from datanfr/improve-blog-section
Move and improve blog section layout
2 parents 50946a1 + 2606518 commit a006d20

File tree

13 files changed

+84
-136
lines changed

13 files changed

+84
-136
lines changed

application/controllers/Home.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public function index() {
9898
$data['candidatRandom']['cardCenter'] = isset($district['libelle']) && $district['libelle'] != '' ? $district['libelle'] . ' (' . $district['id'] . ')' : '';
9999

100100
//Get posts (needs to be cached)
101-
$data['posts'] = $this->post_model->get_last_posts();
101+
$data['posts'] = $this->post_model->get_last_posts(3);
102102

103103
// Composition
104104
$data['composition'] = TRUE;

application/helpers/utility_helper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function css_url(){
88
}
99

1010
function get_version(){
11-
return 91;
11+
return 92;
1212
}
1313

1414
function legislature_current(){

application/models/Post_model.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,16 @@ public function get_post_edit($slug){
4444
return $query->row_array();
4545
}
4646

47-
public function get_last_posts(){
48-
$query = $this->db->query('
49-
SELECT p.id, date_format(created_at, "%d %M %Y") as created_at_fr, p.title, p.body, p.slug, c.slug AS category_slug, c.name AS category_name
50-
FROM posts p
51-
LEFT JOIN categories c ON p.category_id = c.id
52-
WHERE p.state = "published"
53-
ORDER BY created_at DESC
54-
LIMIT 5
55-
');
56-
return $query->result_array();
47+
public function get_last_posts($limit = FALSE){
48+
$this->db->select('p.id, DATE_FORMAT(p.created_at, "%d %M %Y") as created_at_fr, p.title, p.body, p.slug, c.slug AS category_slug, c.name AS category_name');
49+
$this->db->join('categories c', 'p.category_id = c.id', 'left');
50+
$this->db->where('p.state', 'published');
51+
$this->db->order_by('p.created_at', 'DESC');
52+
if ($limit){
53+
$this->db->limit($limit);
54+
}
55+
56+
return $this->db->get('posts p')->result_array();
5757
}
5858

5959
public function create_post(){

application/views/home/index.php

Lines changed: 33 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -99,20 +99,20 @@
9999
</div>
100100
</div>
101101
<!-- VOTES CARDS -->
102-
<div class="row bloc-votes" id="pattern_background">
102+
<div class="row bloc-votes">
103103
<div class="container p-md-0">
104104
<div class="row py-4">
105105
<div class="col-12">
106106
<h2 class="text-center my-4">Derniers votes décryptés par Datan</h2>
107107
</div>
108-
<div class="col-12 carousel-container bloc-carousel-votes-flickity">
108+
<div class="col-12 carousel-container bloc-carousel-votes-flickity mt-4 mb-4">
109109
<?php $this->load->view('votes/partials/votes_carousel.php', array('votes' => $votes)) ?>
110110
<div class="carousel-buttons d-flex justify-content-center">
111111
<button type="button" class="btn prev mr-2 carousel--prev" aria-label="précédent">
112112
<?= file_get_contents(asset_url()."imgs/icons/arrow_left.svg") ?>
113113
</button>
114-
<a class="btn see-all-carousel mx-2" href="<?= base_url() ?>votes/decryptes">
115-
<span>VOIR TOUS LES VOTES</span>
114+
<a class="btn btn-primary mx-2" href="<?= base_url() ?>votes">
115+
Tous les votes
116116
</a>
117117
<button type="button" class="btn next ml-2 carousel--next" aria-label="suivant">
118118
<?= file_get_contents(asset_url()."imgs/icons/arrow_right.svg") ?>
@@ -123,7 +123,7 @@
123123
</div>
124124
</div>
125125
<!-- BLOC COALITION SIMULATEUR -->
126-
<div class="row">
126+
<div class="row"id="pattern_background">
127127
<div class="container py-4">
128128
<div class="row">
129129
<div class="col-12">
@@ -150,30 +150,39 @@
150150
</div>
151151
</div>
152152
</div>
153-
</div>
154-
<!-- BLOC-HASARD -->
155-
<div class="row bloc-hasard">
156-
<div class="container pt-0">
153+
</div>
154+
<!-- BLOC POSTS -->
155+
<div class="row">
156+
<div class="container p-md-0">
157157
<div class="row py-5">
158-
<!-- DEPUTE AU HASARD CARD -->
159-
<div class="<?= $groupe_random ? "col-md-6" : "col-md-12" ?> py-4">
160-
<h2>DÉPUTÉ<?= mb_strtoupper($depute_random['e']) ?> AU HASARD</h2>
161-
<div class="d-flex justify-content-center">
162-
<?php $this->load->view('deputes/partials/card_home.php', array('depute' => $depute_random, 'tag' => 'span', 'footer' => 'discover', 'logo' => true, 'stats' => FALSE)) ?>
158+
<div class="col-lg-12 bloc-posts">
159+
<h3 class="surtitle text-center">Blog</h3>
160+
<h2 class="text-center">Nos analyses et décryptages</h2>
161+
<p class="text-center">L'actualité de Datan, de l'Assemblée nationale et des députés</p>
162+
<div class="row pt-4">
163+
<?php foreach ($posts as $index => $post): ?>
164+
<div class="col-md-4 <?= $index > 0 ? 'mt-md-0 mt-4' : '' ?>">
165+
<div class="article">
166+
<div class="image">
167+
<img class="img-lazy" src="<?= asset_url() ?>imgs/placeholder/placeholder.png" data-src="<?= asset_url() ?>imgs/posts/img_post_<?= $post['id'] ?>.png" alt="Image post <?= $post['id'] ?>" width="480" height="240">
168+
</div>
169+
<div class="mt-2 mb-1">
170+
<span class="category mr-2"><?= mb_strtoupper($post['category_name']) ?></span>
171+
</div>
172+
<h3 class="title mb-0">
173+
<a href="<?= base_url() ?>blog/<?= $post['category_slug'] ?>/<?= $post['slug'] ?>" class="stretched-link no-decoration underline"><?= $post['title'] ?></a>
174+
</h3>
175+
<div>
176+
<span class="date"><?= $post['created_at_fr'] ?></span>
177+
</div>
178+
</div>
179+
</div>
180+
<?php endforeach; ?>
163181
</div>
164182
</div>
165-
<!-- GROUPE AU HASARD CARD -->
166-
<?php if ($groupe_random): ?>
167-
<div class="col-md-6 py-4">
168-
<h2>GROUPE AU HASARD</h2>
169-
<div class="d-flex justify-content-center">
170-
<?php $this->load->view('groupes/partials/card_home.php', array('groupe' => $groupe_random, 'tag' => 'span', 'active' => TRUE, 'cat' => $groupe_random['effectif'] ? $groupe_random['effectif'] . " membres" : "", 'stats' => FALSE)) ?>
171-
</div>
172-
</div>
173-
<?php endif; ?>
174183
</div>
175184
</div>
176-
</div>
185+
</div> <!-- // END BLOC POSTS -->
177186
<!-- BLOC EXPLICATIONS -->
178187
<div class="row bloc-votes" id="pattern_background">
179188
<div class="container p-md-0">
@@ -518,41 +527,6 @@
518527
</div>
519528
</div>
520529
</div> <!-- // END BLOC ILS PARLENT DE NOUS -->
521-
<!-- BLOC POSTS -->
522-
<div class="row">
523-
<div class="container p-md-0">
524-
<div class="row py-5">
525-
<div class="col-lg-12 bloc-posts">
526-
<h2 class="text-center">Blog</h2>
527-
<h2 class="text-center">Nos analyses et décryptages</h2>
528-
<h2 class="text-center">L'actualité de Datan, de l'Assemblée nationale et des parlementaires</h2>
529-
<div class="row pt-4">
530-
<?php foreach ($posts as $post): ?>
531-
<div class="col-12 col-md-6 offset-md-3 col-lg-12 offset-lg-0">
532-
<div class="card card-post my-3">
533-
<div class="row no-gutters">
534-
<div class="col-auto img-wrap d-none d-lg-block">
535-
<img class="img-lazy" src="<?= asset_url() ?>imgs/placeholder/placeholder.png" data-src="<?= asset_url() ?>imgs/posts/img_post_<?= $post['id'] ?>.png" alt="Image post <?= $post['id'] ?>" width="480" height="240">
536-
</div>
537-
<div class="col">
538-
<div class="card-block p-3">
539-
<span class="category mr-2"><?= mb_strtoupper($post['category_name']) ?></span>
540-
<span class="date mr-2">Créé le <?= $post['created_at_fr'] ?></span>
541-
<h2 class="card-title">
542-
<a href="<?= base_url() ?>blog/<?= $post['category_slug'] ?>/<?= $post['slug'] ?>" class="stretched-link no-decoration"><?= $post['title'] ?></a>
543-
</h2>
544-
<p class="card-text"><?= word_limiter(Strip_tags($post['body']), 35) ?></p>
545-
</div>
546-
</div>
547-
</div>
548-
</div>
549-
</div>
550-
<?php endforeach; ?>
551-
</div>
552-
</div>
553-
</div>
554-
</div>
555-
</div> <!-- // END BLOC POSTS -->
556530
<!-- FRANCE MAP -->
557531
<div class="row" id="pattern_background">
558532
<div class="container p-md-0">

application/views/templates/footer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@
197197
<script type="text/javascript" src="<?= asset_url() ?>js/libraries/bootstrap/bootstrap.min.js"></script>
198198
<?php if (isset($js_to_load_before_datan)) : ?>
199199
<?php foreach ($js_to_load_before_datan as $file) : ?>
200-
<script src="<?= asset_url(); ?>js/<?= $file ?>.js"></script>
200+
<script src="<?= asset_url(); ?>js/<?= $file ?>.js?v=<?= get_version() ?>"></script>
201201
<?php endforeach; ?>
202202
<?php endif; ?>
203203
<script type="text/javascript" src="<?= asset_url() ?>js/libraries/jquery/jquery.unveil.min.js"></script>

application/views/templates/header.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,19 +104,19 @@
104104

105105
<?php if (isset($css_to_load)): ?>
106106
<?php foreach ($css_to_load as $file): ?>
107-
<link type="text/css" <?php if ($file['async']): ?> rel="stylesheet" media="print" onload="this.media='all';this.onload=null;" <?php else: ?> rel="stylesheet" <?php endif; ?> href="<?= $file['url'] ?>"/>
107+
<link type="text/css" <?php if ($file['async']): ?> rel="stylesheet" media="print" onload="this.media='all';this.onload=null;" <?php else: ?> rel="stylesheet" <?php endif; ?> href="<?= $file['url'] ?>?v=<?= get_version() ?>"/>
108108
<?php endforeach; ?>
109109
<?php endif; ?>
110110

111111
<!-- JS_UP -->
112112
<?php if (isset($js_to_load_up)): ?>
113113
<?php foreach ($js_to_load_up as $file): ?>
114-
<script src="<?= asset_url().'js/'.$file ?>"></script>
114+
<script src="<?= asset_url().'js/'.$file ?>?v=<?= get_version() ?>"></script>
115115
<?php endforeach; ?>
116116
<?php endif; ?>
117117
<?php if (isset($js_to_load_up_defer)): ?>
118118
<?php foreach ($js_to_load_up_defer as $file): ?>
119-
<script defer src="<?= asset_url().'js/'.$file ?>"></script>
119+
<script defer src="<?= asset_url().'js/'.$file ?>?v=<?= get_version() ?>"></script>
120120
<?php endforeach; ?>
121121
<?php endif; ?>
122122

application/views/votes/all.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
<button type="button" class="btn prev mr-2 carousel--prev" aria-label="précédent">
3030
<?= file_get_contents(asset_url()."imgs/icons/arrow_left.svg") ?>
3131
</button>
32-
<a class="btn see-all-carousel mx-2" href="<?= base_url() ?>votes/decryptes">
33-
<span>VOIR TOUS LES VOTES</span>
32+
<a class="btn btn-primary mx-2" href="<?= base_url() ?>votes/decryptes">
33+
Tous les votes
3434
</a>
3535
<button type="button" class="btn next ml-2 carousel--next" aria-label="suivant">
3636
<?= file_get_contents(asset_url()."imgs/icons/arrow_right.svg") ?>
@@ -106,8 +106,8 @@
106106
<button type="button" class="btn prev mr-2 carousel--prev" aria-label="précédent">
107107
<?= file_get_contents(asset_url()."imgs/icons/arrow_left.svg") ?>
108108
</button>
109-
<a class="btn see-all-carousel mx-2" href="<?= base_url() ?>votes/decryptes">
110-
<span>VOIR TOUS LES VOTES</span>
109+
<a class="btn btn-primary mx-2" href="<?= base_url() ?>votes/decryptes">
110+
Tous les votes
111111
</a>
112112
<button type="button" class="btn next ml-2 carousel--next" aria-label="suivant">
113113
<?= file_get_contents(asset_url()."imgs/icons/arrow_right.svg") ?>

application/views/votes/individual.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,8 +499,8 @@
499499
<button type="button" class="btn prev mr-2 carousel--prev" aria-label="précédent">
500500
<?= file_get_contents(asset_url() . "imgs/icons/arrow_left.svg") ?>
501501
</button>
502-
<a class="btn see-all-carousel mx-2" href="<?= base_url() ?>votes/decryptes">
503-
<span>VOIR TOUS LES VOTES</span>
502+
<a class="btn btn-primary mx-2" href="<?= base_url() ?>votes/decryptes">
503+
Tous les votes
504504
</a>
505505
<button type="button" class="btn next ml-2 carousel--next" aria-label="suivant">
506506
<?= file_get_contents(asset_url() . "imgs/icons/arrow_right.svg") ?>

assets/css/critical/index-mobile.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/css/critical/index.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)