Back to Opencart

File extension\opencart\catalog\controller\module\blog.php

docs/api/source-extension.opencart.catalog.controller.module.blog.html

4.1.0.37.2 KB
Original Source

Namespaces

Classes

| 1: | <?php | | 2: | namespace Opencart\Catalog\Controller\Extension\Opencart\Module; | | 3: | /** | | 4: | * Class Blog | | 5: | * | | 6: | * @package Opencart\Catalog\Controller\Extension\Opencart\Module | | 7: | */ | | 8: | class Blog extends \Opencart\System\Engine\Controller { | | 9: | /** | | 10: | * Index | | 11: | * | | 12: | * @param array<string, mixed> $setting | | 13: | * | | 14: | * @return string | | 15: | */ | | 16: | public function index(array $setting): string { | | 17: | $this->load->language('extension/opencart/module/blog'); | | 18: | | | 19: | $data['blogs'] = []; | | 20: | | | 21: | $this->load->model('extension/opencart/module/blog'); | | 22: | $this->load->model('tool/image'); | | 23: | | | 24: | $filter_data = [ | | 25: | 'sort' => $setting['sort'], | | 26: | 'order' => $setting['order'], | | 27: | 'start' => 0, | | 28: | 'limit' => $setting['limit'] | | 29: | ]; | | 30: | | | 31: | $results = $this->model_extension_opencart_module_blog->getArticles($filter_data); | | 32: | | | 33: | if ($results) { | | 34: | foreach ($results as $result) { | | 35: | if ($result['image']) { | | 36: | $image = $this->model_tool_image->resize(html_entity_decode($result['image'], ENT_QUOTES, 'UTF-8'), $setting['width'], $setting['height']); | | 37: | } else { | | 38: | $image = $this->model_tool_image->resize('placeholder.png', $setting['width'], $setting['height']); | | 39: | } | | 40: | | | 41: | $data['blogs'][] = [ | | 42: | 'article_id' => $result['article_id'], | | 43: | 'thumb' => $image, | | 44: | 'name' => $result['name'], | | 45: | 'description' => oc_substr(trim(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8'))), 0, $this->config->get('config_article_description_length')) . '..', | | 46: | 'href' => $this->url->link('cms/blog.info', 'language=' . $this->config->get('config_language') . '&article_id=' . $result['article_id']) | | 47: | ]; | | 48: | } | | 49: | | | 50: | return $this->load->view('extension/opencart/module/blog', $data); | | 51: | } else { | | 52: | return ''; | | 53: | } | | 54: | } | | 55: | } | | 56: | |

OpenCart API API documentation generated by ApiGen dev-master