V
V
Vitaly Melnichuk2015-11-13 20:34:24
PHP
Vitaly Melnichuk, 2015-11-13 20:34:24

How to display your category title by id Opencart?

There is a task to display your title in the Open Cart category.
Brought it out like this

<?php
 //print $_SERVER['REQUEST_URI'];
  //print strripos($_SERVER['REQUEST_URI'], '/index.php?route=product/category&path=20');
        if (strripos($_SERVER['REQUEST_URI'], '/bankovskie')>-1)
        {
        print "<title>Свой Тайтл</title>";
        }
        
        else
        {
                print "<title>$title</title>";
        }
        ?>

Everything seems to be ok, but if you go to the bankovskie category, and there are 3 subcategories in it, then the title takes from bankovskie.
How can I make it work only in the main category?
Without CNC everything is ok, but you need CNC.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
wol_fi, 2015-11-13
@vitalik_melnichyk

$tokens = explode('/', $_SERVER['REQUEST_URI']);
if (strpos('bankovskie', end($tokens)) !== false) {
   print "<title>Свой Тайтл</title>";
} else {
   print "<title>$title</title>";
}

But this is the wrong approach. Make it possible to set a title from the backend, and display it like everyone else.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question