1084

Injecting Modules in Themes

Comments for “Injecting Modules in Themes”
 

Posted by DaddyJohn on Thursday 7th April 2022 at 07:33 GMT

Looking at the docs, we can call modules from view files which I fully understand. However, if we have downloaded a Theme, can we create a module and then call it from the Theme folders?

For example, lets say I have downloaded the Powerhouse Theme, but want to add another section into the page that covers events. I would want to create an events module and then call this within powerhouse.php

How would we do this?

Thanks
Early Adopter

DaddyJohn

User Level: Early Adopter

Date Joined: 23/01/2022

Posted by djnordeen on Thursday 7th April 2022 at 15:56 GMT

Hello,
Here is what I think you are asking.
https://trongate.io/docs_m/information/calling-another-module-from-a-view
 Modules::run('second_modules/some_method') 

Change it to call events module and then the method name
 Modules::run('events/some_method') 

This comment was edited by djnordeen on Thursday 7th April 2022 at 15:58 GMT

Early Adopter

djnordeen

User Level: Early Adopter

Date Joined: 20/08/2021

Posted by DaddyJohn on Thursday 7th April 2022 at 16:11 GMT

Hi, thanks for this, but I already tried this.

modules::run('events/all_events')

but I got the error message

Warning: Constant THEME_DIR already defined in C:\xampp\htdocs\restaurant_v1\engine\bootstrap.php on line 25

This comment was edited by DaddyJohn on Thursday 7th April 2022 at 16:12 GMT

Early Adopter

DaddyJohn

User Level: Early Adopter

Date Joined: 23/01/2022

Posted by djnordeen on Thursday 7th April 2022 at 16:35 GMT

What is the name of your theme?
Are you calling the module from the view file or a controller file?

Another thought
this line in the templates folder
    function powerhouse($data) {
        load('powerhouse', $data);
    }

This comment was edited by djnordeen on Thursday 7th April 2022 at 16:45 GMT

Early Adopter

djnordeen

User Level: Early Adopter

Date Joined: 20/08/2021

Posted by DaddyJohn on Thursday 7th April 2022 at 21:49 GMT

I decided against using the Theme approach to build and have gone back to using Templates.

I was getting very confused about the way TG uses Themes and Templates, but the video from DC tonight on You-Tube has cleared things up in my mind.

Everything is working fine now.

Thanks for all of your help.

I am very lucky to have found this community, your help is always highly appreciated.

This comment was edited by DaddyJohn on Thursday 7th April 2022 at 21:50 GMT

Early Adopter

DaddyJohn

User Level: Early Adopter

Date Joined: 23/01/2022

Posted by djnordeen on Friday 8th April 2022 at 00:43 GMT

Your welcome
Early Adopter

djnordeen

User Level: Early Adopter

Date Joined: 20/08/2021

Posted by Davcon on Friday 8th April 2022 at 12:21 GMT

Yeah man. I would only recommend building themes if you're planning on distributing themes via the Module Market.

Thanks for helping John out. If you see this message, John, please resolve the thread by giving somebody a tick (but not me).

Cheers!

This comment was edited by Davcon on Friday 8th April 2022 at 12:21 GMT

Founding Member

Davcon

User Level: Founding Member

Date Joined: 3/11/2018

×