Search code examples
phpelgg

php fatal error "undefined function" for a function in an elgg plugin library


I am trying to write a plugin for elgg that's similar to the bookmarks plugin. I found out php doesn't do "innerHTML," so I added some code to my plugin's library to accomplish that. But I am getting this error:

PHP Fatal error: Call to undefined function DOMinnerHTML() in /var/www/html/mod/mypluginname/actions/mypluginname/save_address.php on line 71, referer: http://www.example.com/mypluginname/add_address/49

The calling code:

mytitle =  $doc->getElementById('myTitle');
if($mytitle){
   $title = DOMinnerHTML($mytitle);
}

Line 71 of /var/www/html/mod/mypluginname/actions/mypluginname/save_address.php is:

$title=DOMinnerHTML($mytitle);

The function is in /var/www/html/mod/mypluginname/lib/mypluginname.php:

function DOMinnerHTML(DOMNode $element)
{
   $innerHTML = "";
   $children  = $element->childNodes;

   foreach ($children as $child)
   {
      $innerHTML .= $element->ownerDocument->saveHTML($child);
   }
   return $innerHTML;
}

Any idea why this function isn't considered "defined?"


Solution

  • You have to include or require mypluginname.php ?