Post by xintersecty » Wed Sep 05, 2018 9:01 am

I am a new programmer working on opencart Version 3.0.2.0. I have made a controller, and trying to get the language file and view files to work.
This is the URL for accessing the controller:
https://www.testsystem.com/index.php?ro ... tcode/test

Here is the output of the controller:
Hello World The view goes here

The location of the controller: catalog/language/en-gb/testcode
Here is the code for the controller

Code: Select all

<?php
class ControllerTestcodeTest extends Controller{
     public function index()
     {
		 // set the heading_title of the module
		$this->data['heading_title'] = $this->language->get('heading_title'); 
		echo 'Hello World ';
		echo 'The view goes here';
		//$this->load->view('testcode/test', $data);
		//$this->response->setOutput($this->load->view('testcode/test', $data));
		$this->render(); // renders the output
        exit;
     }
}
?>
The location of the view: catalog/view/theme/default/template/testcode
Here is the view code:

Code: Select all

<div class="testcode">
    <h2>IT WORKED IT WORKED!</h2>
    <p>Hey Some text showed up in this paragraph</p>
</div> 
Here is my language file and I have place it various places it did not seem to help.

Code: Select all

<?php
    // Heading 
    $_['heading_title']  = 'Test Code Test Title';
?>
I know everything is bare bones I am just trying to get it to work with out errors

Now for the kicker the error log from opencart

Code: Select all

2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'code' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'direction' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'date_format_short' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'date_format_long' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'time_format' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'datetime_format' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'decimal_point' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'thousand_point' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'text_home' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'text_yes' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'text_no' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'text_none' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'text_select' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'text_all_zones' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'text_pagination' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'text_loading' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'text_no_results' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'button_address_add' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'button_back' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'button_continue' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'button_cart' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'button_cancel' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'button_compare' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'button_wishlist' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'button_checkout' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'button_confirm' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'button_coupon' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'button_delete' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'button_download' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'button_edit' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'button_filter' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'button_new_address' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'button_change_address' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'button_reviews' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'button_write' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'button_login' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'button_update' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'button_remove' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'button_reorder' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'button_return' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'button_shopping' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'button_search' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'button_shipping' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'button_submit' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'button_guest' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'button_view' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'button_voucher' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'button_upload' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'button_reward' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'button_quote' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'button_list' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'button_grid' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'button_map' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'error_exception' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'error_upload_1' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'error_upload_2' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'error_upload_3' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'error_upload_4' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'error_upload_6' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'error_upload_7' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'error_upload_8' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'error_upload_999' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'error_curl' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'datepicker' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Illegal string offset 'backup' in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Notice:  Array to string conversion in /home/testsys/public_html/catalog/controller/event/language.php on line 6
2018-09-05 0:23:43 - PHP Warning:  Invalid argument supplied for foreach() in /home/testsys/public_html/system/engine/loader.php on line 121

So at the end of it all, I may not have the right language location or enough stuff in the language files. Or the module really does need to be registered. I want to try to get the different sub-sections working with the need to learn the installer.

Newbie

Posts

Joined
Tue May 29, 2018 8:07 am

Post by straightlight » Wed Sep 05, 2018 10:11 pm

See this documentation as an OC starter: https://github.com/opencart/opencart/wi ... -Standards

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by xintersecty » Fri Sep 07, 2018 12:19 am

I appreciate the link the coding standards but it does not help me in chasing down a root cause. I need to understand if the 3.0 system needs to have the language file in an internal catalog or a certain file location.

Newbie

Posts

Joined
Tue May 29, 2018 8:07 am

Post by straightlight » Fri Sep 07, 2018 12:25 am

Each language files are independent based on the ones you decide to contribute whether originating from OCMod or from an event by default.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by xintersecty » Wed Sep 12, 2018 5:58 am

Still looking for how the 3.0 system picks up the language file. Take a look at the errors.

Newbie

Posts

Joined
Tue May 29, 2018 8:07 am

Post by straightlight » Wed Sep 12, 2018 8:41 pm

xintersecty wrote:
Wed Sep 12, 2018 5:58 am
Still looking for how the 3.0 system picks up the language file. Take a look at the errors.
All controllers by default calls for their referred language folder and file (without PHP extension) with the use of:

Code: Select all

$this->load->language('folder/language_file');
Which the folder[/b] is the sub-folder under the catalog/language/<your_language_code>/folder and the language_file which would your actual PHP language file. Documentation about languages: http://docs.opencart.com/en-gb/developer/loading/

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by xintersecty » Thu Sep 13, 2018 7:35 pm

Straightlight! Thanks very much for your help! That got me over my error hump. Just a few lines changed and huge amounts of understanding! So THANKS!

New code in the controller

Code: Select all

<?php
class ControllerTestcodeTest extends Controller{
     public function index()
     {
		$data['results'] = " ";
		$this->load->language('module/test');
		// set the heading_title of the module		 
		$data['heading_title'] = $this->language->get('heading_title'); 
		echo 'Hello World ';
		echo 'The view goes here';
		return $this->response->setOutput($this->load->view('testcode/test', $data));
     }
}
?>

Newbie

Posts

Joined
Tue May 29, 2018 8:07 am

Post by straightlight » Thu Sep 13, 2018 7:50 pm

If your store is running live, it would rather be best to first login to your OC admin and then access your store with these codes:

Code: Select all

<?php
class ControllerTestcodeTest extends Controller {
     public function index()
     {
     		$this->load->language('module/test');
     		
		$data['results'] = " ";		
		
		// set the heading_title of the module		 
		
		$data['heading_title'] = $this->language->get('heading_title'); 
		
		if (!empty($this->session->data['user_token'])) {
			echo 'Hello World ';
		
			echo 'The view goes here';
		}
				
		return $this->response->setOutput($this->load->view('testcode/test', $data));
     }
}
?>
so that only admins will be able to see the echoed messages.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: No registered users and 428 guests