Page 1 of 1

[SOLVED] creating module - can't see my functions

Posted: Thu Jul 31, 2008 2:22 pm
by turniphead
I'm developing my first module using the documentation and skeleton module as a reference. I'm using a one-file approach with one .module.php file. All was going well until I tried to bundle some of my code in a function. So I have something like

Code: Select all

function myfunction() 
{
  return "myfunction";
}

function DoAction($action, $id, $params, $returnid=-1)
{
.
.
.

  if ($action == 'addproduct')
  {
    $x=myfunction();
  }
.
.
.
}
This arrangement gives me
Fatal error: Call to undefined function myfunction()
Can anyone explain why?

Re: creating module - can't see my functions

Posted: Fri Aug 01, 2008 5:39 am
by oi_antz
When you're working within a class such as "class MyNewModule extends CMSModule{...}", you need to reference methods by $this->myFunction() instead of just myFunction(). Look for a tutorial on OOP with PHP, this will explain how to use classes and objects.

Re: [SOLVED] creating module - can't see my functions

Posted: Fri Aug 01, 2008 5:18 pm
by turniphead
Of course!

Thank you.