Answer the question
In order to leave comments, you need to log in
How to display the variable I created (Opencart) on the page? What is responsible for displaying variables in the common/header.tpl file?
I need to display the name of the new (logged in) client in header.tpl. The first step I decided to go to the controller and create a variable there with random content, display it on the page. In the controller, looking at how other variables are set, I write:
$data['customer_name'] = 'Sergey';
или
$this->data['customer_name'] = 'Sergey';
Undefined variable: customer_name in /vqmod/vqcache/vq2-catalog_view_theme_default_template_common_header.tpl
Answer the question
In order to leave comments, you need to log in
the error
Undefined variable: customer_name in /vqmod/vqcache/ ...
says that you should clear the cache, i.e. delete contents of vqcache
In header.php
if ($this->customer->isLogged()) {
$data['welcome_message'] = sprintf("Добро пожаловать, %s!", $this->customer->getFirstName());
}
<div><?php if (isset($welcome_message)) { echo $welcome_message; } ?></div>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question