phphtmlopencartopencart2.3

Undefined variable: meta_keyword


I am using opencart 2.3.0.2 on xampp and I have this issue when I load the language file to the view it doesn't work here's the controller C:\xampp\htdocs\opencart2302\catalog\controller\product\categorieslist.php:

<?php 
class ControllerProductCategoriesList extends Controller {
    public function index(){
        $this->load->language('product/categorieslist');

        $data = array();

        $data['test'] = "this is text from controller";

        $this->response->setOutput($this->load->view('product/categorieslist',$data));
    }
    // public function add(){
    //     echo "this is add method call from CPC";
    // }
}

?>

and here's the language file
C:\xampp\htdocs\opencart2302\catalog\language\en-gb\product\categorieslist.php :

 <?php 
//Text
$_['title']             = 'All Categories';
$_['meta_title']        = 'All Categories';
$_['meta_description']  = 'All Categories';
$_['meta_keyword']      = 'All Categories';
$_['categories_text']   = 'This is categories list page 2';

and here's the view file C:\xampp\htdocs\opencart2302\catalog\view\theme\default\template\product\categorieslist.tpl :

 <?php echo $meta_keyword; ?>
<?php echo $test; ?>

Solution

  • In your controller file you must define meta_keyword

    after

    $data['test'] = "this is text from controller";
    

    add

    $data['meta_keyword'] = $this->language->get('meta_keyword');