D
D
Dmitry Cherednichenko2014-07-08 17:25:21
Kohana
Dmitry Cherednichenko, 2014-07-08 17:25:21

How to display $title variable from Kohana controller?

Hello! Can't display variable with page title.
In the main controller, it is declared like this:

public function before() {
        parent::before();
        View::set_global('title', 'Мой сайт');				
    }

In the general template, I display the header like this: There is a Products controller with products. The data is stored in the database. In the View, product data is displayed using: Get to the point. I cannot pass a variable with the page title from the database to the Products controller. I do it like this:
<title><?php echo $title; ?></title>
echo $product['xxx'];
public function action_product()
    {	
    
    $this->template->title = $product['title'];
    }

and i get an error
ErrorException [ Notice ]: Undefined variable: product

APPPATH\classes\Controller\Products.php [ 14 ]

If you declare $title like this
public function action_product()
    {	
    
    $this->template->title ='Text';
    }

then "Text" will be displayed in the title of the page. What am I doing wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yakov Akulov, 2014-07-08
@likeapimp

The error says that you are doing something wrong:
Where is the $product variable declared?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question