blog_latest.php
1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
// * @source See SOURCE.txt for source and other copyright.
// * @license GNU General Public License version 3; see LICENSE.txt
class ControllerExtensionModuleBlogLatest extends Controller {
public function index($setting) {
$this->load->language('extension/module/blog_latest');
$this->load->model('blog/article');
$this->load->model('tool/image');
$data['articles'] = array();
$filter_data = array(
'sort' => 'p.date_added',
'order' => 'DESC',
'start' => 0,
'limit' => $setting['limit']
);
$results = $this->model_blog_article->getArticles($filter_data);
if ($results) {
foreach ($results as $result) {
if ($result['image']) {
$image = $this->model_tool_image->resize($result['image'], $setting['width'], $setting['height']);
} else {
$image = $this->model_tool_image->resize('placeholder.png', $setting['width'], $setting['height']);
}
if ($this->config->get('configblog_review_status')) {
$rating = $result['rating'];
} else {
$rating = false;
}
$data['articles'][] = array(
'article_id' => $result['article_id'],
'thumb' => $image,
'name' => $result['name'],
'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get('configblog_article_description_length')) . '..',
'rating' => $rating,
'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])),
'viewed' => $result['viewed'],
'href' => $this->url->link('blog/article', 'article_id=' . $result['article_id'])
);
}
return $this->load->view('extension/module/blog_latest', $data);
}
}
}