I making custom form template and i curious.

myfatebiz

Active Member
Hi,

Inside default.php why using echo $this->loadTemplate instead include?.

If using $this->loadTemplate, i can't pass variable into it but if using include i can pass it.

It's okay if i using include instead $this->loadTemplate?.

Thanks in advance.
 
What variable and from where are you trying to pass?

I using my own custom plugin which is it's load custom loader namespace from my folder. Under form template on default.php i load my class like below:

$Helper = new Forms\MyCustomClassFolder\Helper;

then i try to call $Helper variable inside default_group.php it's not gonna work because of this file called by using $this->loadTemplate('group') unless i change it into include 'default_group.php' then $Helper variable be able to use in there.

My question is here are there is bad practice to using include instead $this->loadTemplate()
 
OK, seems more clear now. I think this should be commented by someone more deeply familiar with Fabrik source code. But if it works as expected, I personally don't see any downsides of including your own helper file in template.
 
OK, seems more clear now. I think this should be commented by someone more deeply familiar with Fabrik source code. But if it works as expected, I personally don't see any downsides of including your own helper file in template.

It's working as expected. I'm just feel unease because need to change the way calling the file $this->loadTemplate('group') to include 'default_group.php'.

I have other option in my mind. I just do the class call for each file but the code seem look like unclean because same template need to call class for each file. :(
 
Yes!!!!!!. I finally found the solution. I just assign another $this value for my helper like below.

1. First at my default.php i need to call my class.

$Helper = new Forms\MyCustomClassFolder\Helper;

2. Assign that variable into $this.

$this->Helper = $Helper;

3. Then i can call that anywhere in the file.

echo $this->Helper->MyFunction;

Now i can use $this->loadTemplate('group').

I so happy now. ;)
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top