1: | <?php
|
2: | namespace Opencart\Catalog\Controller\Extension\Opencart\Module;
|
3: | |
4: | |
5: | |
6: | |
7: |
|
8: | class Topic extends \Opencart\System\Engine\Controller {
|
9: | |
10: | |
11: | |
12: | |
13: |
|
14: | public function index(): string {
|
15: | $this->load->language('extension/opencart/module/topic');
|
16: |
|
17: | if (isset($this->request->get['topic_id'])) {
|
18: | $data['topic_id'] = (int)$this->request->get['topic_id'];
|
19: | } else {
|
20: | $data['topic_id'] = 0;
|
21: | }
|
22: |
|
23: | $url = '';
|
24: |
|
25: | if (isset($this->request->get['sort'])) {
|
26: | $url .= '&sort=' . $this->request->get['sort'];
|
27: | }
|
28: |
|
29: | if (isset($this->request->get['order'])) {
|
30: | $url .= '&order=' . $this->request->get['order'];
|
31: | }
|
32: |
|
33: | $data['topics'] = [];
|
34: |
|
35: | $data['topics'][] = [
|
36: | 'topic_id' => 0,
|
37: | 'name' => $this->language->get('text_all') . ($this->config->get('config_article_count') ? ' (' . $this->model_cms_article->getTotalArticles() . ')' : ''),
|
38: | 'href' => $this->url->link('cms/blog', 'language=' . $this->config->get('config_language') . $url)
|
39: | ];
|
40: |
|
41: | $this->load->model('cms/topic');
|
42: | $this->load->model('cms/article');
|
43: |
|
44: | $topics = $this->model_cms_topic->getTopics();
|
45: |
|
46: | foreach ($topics as $topic) {
|
47: | $data['topics'][] = [
|
48: | 'topic_id' => $topic['topic_id'],
|
49: | 'name' => $topic['name'] . ($this->config->get('config_article_count') ? ' (' . $this->model_cms_article->getTotalArticles(['filter_topic_id' => $data['topic_id']]) . ')' : ''),
|
50: | 'href' => $this->url->link('cms/blog', 'language=' . $this->config->get('config_language') . '&topic_id=' . $topic['topic_id'] . $url)
|
51: | ];
|
52: | }
|
53: |
|
54: | return $this->load->view('extension/opencart/module/topic', $data);
|
55: | }
|
56: | }
|
57: | |