S
S
Siimple2018-07-15 17:31:37
opencart
Siimple, 2018-07-15 17:31:37

Variable output in OpenCart header?

Hello! I have implemented a function in which I can insert a variable in the admin in the category title and the value of this variable is displayed.
I want to copy and implement the same for the name, but it doesn't work. Maybe someone will tell. Thanks in advance
It was like this: (catalog/controller/product/category.php)

if ($category_info) {
      
      $m = $category_info['meta_title'];
      $d = $category_info['meta_description'];
      $t = $this->config->get('config_new');
      $new_title = str_replace('names', $t, $m);
      $new_desc = str_replace('names', $t, $d);
      $this->document->setTitle($new_title);
      $this->document->setDescription($new_desc);

I duplicated and added more for the title, but it doesn't show up. As a result, it turned out like this:
if ($category_info) {
      
      
      $m = $category_info['meta_title'];
      $d = $category_info['meta_description'];
      $a = $category_info['meta_h1'];
      $t = $this->config->get('config_new');
      $new_title = str_replace('names', $t, $m);
      $new_desc = str_replace('names', $t, $d);
      $new_h1 = str_replace('names', $t, $a);
      $this->document->setTitle($new_title);
      $this->document->setDescription($new_desc);
      $this->document->setDescription($new_h1);

$category_info['meta_h1']; - I have an h1 tag - a field in the admin panel in the categories, it is replaced instead of the title.
if ($category_info['meta_h1']) {
        $data['heading_title'] = $category_info['meta_h1'];
      } else {
        $data['heading_title'] = $category_info['name'];
      }

It works everywhere, but doesn't work in meta_h1.
5b4b5ac689113850230845.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Z
zoozag, 2018-07-16
@Simple

$this->document->setDescription($new_h1);- delete

$data['heading_title'] = $category_info['meta_h1'];
- replace with $data['heading_title'] = $new_h1;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question