phpopencart

Opencart how to add everything from the language file in php loop


It there a way to read everything from within a language with Opencart?

At the moment I have to:

Controller
$this->load->language('help');          
$this->data['heading_title'] = $this->language->get('heading_title');    
$this->data['tab1'] = $this->language->get('tab1');

Language File

<?php
// Heading
$_['heading_title']      = 'Help';
$_['tab1'] = 'Account';    
?>

Solution

  • The easiest thing to do is to use array merge at the top of your controller

    $this->data = array_merge($this->data, $this->language->load('language/file'));
    

    or simply

    $this->data += $this->language->load('language/file');
    

    Edit

    For 2.x, use

    $data = array_merge($this->data, $this->language->load('language/file'));

    3.x does this automatically