A
A
AltaiR2017-03-07 15:02:48
PHP
AltaiR, 2017-03-07 15:02:48

How to display an article on the main page in opencart?

Hi all. How to display the incomplete text of the article on the main page in opencart with the "more" button at the bottom to go to the page of the article where the full text is already? In wordpress, I could put the separator where I needed in the editor and then display it in the right one using the_content(); , but in opencart I don't know how to do it.
PS I found such a solution, can I somehow change it so that the id is already passed in the template file itself? So I want to display several articles.

$this->load->language('information/information');
$this->load->model('catalog/information');
$information_id = 4;
$information_info = $this->model_catalog_information->getInformation($information_id);
$data['heading_title'] = $information_info['title'];
$data['description'] = html_entity_decode($information_info['description'], ENT_QUOTES, 'UTF-8');
$data['link_continue'] = $this->url->link('information/information', 'information_id=' .  $information_id);
$data['button_continue'] = $this->language->get('button_continue');

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
Grigory Vasilkov, 2017-03-08
@AltaiR-05

Well, look, in OC - "model" is a file with query commands and result processing.
You "connect" it...
...and then call the method from there, passing the parameter to the function

$information_id = 4;
$information_info = $this->model_catalog_information->getInformation($information_id);

Now you have data in some form in $information_info (more on this in the model file itself - there are processing and queries).
You need to output this data in some kind of "template" - it so happened that in OC templates are called the same as action files - "controllers". The main one is handled by /controllers/common/home.php
In this file, at the very bottom, there is a template call, to which the $data variable is passed. In this $data you need to save your data, and they will be available in the template file that is called there.
In the template, already output, if you want in a cycle, if you want with other templates, there are a lot of ways.

K
k0nsu1, 2017-03-07
@k0nsu1

In the common/home controller, you need to do something like $this->load->model('information/information');
Next $data['article'] = $this->model_information_information->getInformation(article number);
Access the $article variable in the template

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question