P
P
Peter2015-12-12 16:20:39
opencart
Peter, 2015-12-12 16:20:39

How can I tell which page I'm on in the header?

In the controller->common->header block, I need to determine which page I am currently on, an article, or a product card, or a basket, or a category, etc.
How can I do it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Shcherbakov, 2015-12-12
@volkov_p_v

Under OP 1.5 one could use a construct like:

<?php if (!isset($this->request->get['route'])) {
    $this->request->get['route']='common/home'; // Чтобы не выдавало ошибку, если юзер набрал адрес в браузере руками
  } ?>
  <?php if ($this->request->get['route']=='common/home') { ?>
    <li>
      <a href="/" class="active">Главная</a>
    </li>
  <?php } else { ?>
    <li>
      <a href="/">Главная</a>
    </li>
  <?php } ?>

I pulled from an ancient project where it was necessary to display two different link designs. Under OP2.0, you just need to see how routing is checked.
What version do you have?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question