Jump to content

[Module] Varibale "$This->L('blabla') Is Not Defined.


Recommended Posts

hello all,

 

I am having issues with a error which is showing on the "https://validator.prestashop.com/"

 

Error:

Variable $this is undefined.

Example of error:

<p>'. $this->l('Content') .'</p>

so i have a module, lets call it "testmodule"

if i use the $this->l('Content') inside testmodule.php it gives no error.

But when i add a php page for example additional_page.php it says the variable is not defined.

 

Any clues which file i need to include in order to define the variable?

using $this = '' at the start of the page doesn't work!

 

Kind regards

Jaimy

 

Link to comment
Share on other sites

Try this code:

$testModule = Module::getInstanceByName('testmodule');
echo $testModule->l('test', 'additional_page');

This is the main idea, so just replace "testmodule" and "additional_page" by relevant values and use $testModule->l() where you need.

Link to comment
Share on other sites

i am receiving this error

 

Error:

Fatal error: Call to a member function l() on a non-object in /home/.../sendmail.php on line 23
[PrestaShop] Fatal error in module file :/home/.../sendmail.php:
Call to a member function l() on a non-object

Code:

$testModule = Module::getInstanceByName('Newsletterbuilderandsender');
echo $testModule->l('test', 'sendmail');

kind regards

Jaimy

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...