Post by Danial5621 » Tue May 30, 2023 5:33 pm

I have my own module with several fields. I want to show this data on the contact page and in the header. How to connect this module for example to the contact page controller?

I have tried connect it like this: mythdhr

Code: Select all

$data['mymodule'] = $this->load->controller('extension/module/mymodule');
But nothing. What do I need to do?

Newbie

Posts

Joined
Tue May 23, 2023 5:24 pm

Post by ADD Creative » Tue May 30, 2023 11:20 pm

What version of OpenCart? Do you know your module is actually returning anything? Are your header or contact template files using the 'mymodule' data?

www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by straightlight » Wed May 31, 2023 4:25 am

Posted in the wrong forum section.

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 DigitCart » Wed May 31, 2023 5:46 pm

​Hi

If you want to show some static information, You can use the default HTML contents module.​

My Extensions


User avatar
Active Member
Online

Posts

Joined
Thu Jun 22, 2017 5:32 pm


Post by AquaJeth55 » Sat Jan 20, 2024 3:16 pm

Danial5621 wrote:
Tue May 30, 2023 5:33 pm
I have my own module with several fields. I want to show this data on the contact page and in the header. How to connect this module for example to the contact page controller?

I have tried connect it like this: Subway Listens

Code: Select all

$data['mymodule'] = $this->load->controller('extension/module/mymodule');
But nothing. What do I need to do?
Hello! To show data from your module on the contact page and in the header, you will need to connect your module to the appropriate controller. Here is an example of how you can do this:

Code: Select all

// Load the module controller
$this->load->controller('extension/module/mymodule');

// Get the data from the module
$my_data = $this->model_extension_module_mymodule->getData();

// Pass the data to the view
$data['my_data'] = $my_data;

// Load the contact page view
$this->response->setOutput($this->load->view('common/contact', $data));
In this example, we are loading the `mymodule` controller and getting the data from the `getData()` method in the `model_extension_module_mymodule` model. We then pass this data to the `common/contact` view using the `$data` array.

I hope this helps! Let me know if you have any other questions.

Newbie

Posts

Joined
Sat Jan 20, 2024 3:09 pm
Who is online

Users browsing this forum: No registered users and 13 guests