I have just installed my jommla 1.5 in my computer. I have been trying out the hello world codes that I have found in the documentation in the manuals.
I have no problems with the code when I am using only one file. But when I introduce the hello.html.php file, I get the following error message:
'Fatal error: require_once() [function.require]: Failed opening required '' (include_path='.;C:\xampp\php\pear\') in C:\xampp\htdocs\joomla15\components\com_helloworld\helloworld.php on line 5'
The codes are as follows:
helloworld.php
<?php
defined('_JEXEC') or die('Restricted access');
// require the html view class
require_once (JApplicationHelper :: getPath('front_html', 'com_hello'));
$task = JRequest::getVar('task');
$name = JRequest::getVar('name', 'John');
switch ($task) {
case 'show':
default:
hello_HTML::show($name);
break;
}
?>
helloworld.html.php
<?php
// no direct access
defined('_JEXEC') or die('Access to this file is probibited');
class hello_HTML {
function show($name) {
echo 'Welcome ' . $name . ' to our World!';
}
}
?>
can someone tell me what is wrong and how do i correct it?
Error in my component for Hello World
Moderators: tjay, seadap, Rogue4ngel, matthewhayashida
Re: Error in my component for Hello World
Welcome to the forum!
Try this code:
Try this code:
Code: Select all
<?php
defined('_JEXEC') or die('Restricted access');
// require the html view class
jimport( 'joomla.application.helper' );
require_once (JApplicationHelper :: getPath('front_html', 'com_hello'));
$task = JRequest::getVar('task');
$name = JRequest::getVar('name', 'John');
switch ($task) {
case 'show':
default:
hello_HTML::show($name);
break;
}
?>
Gergo Erdosi
Re: Error in my component for Hello World
Thank you. It is working now.
Do I have to import any functions that I need or is this an environment setting that I might have missed?
Do I have to import any functions that I need or is this an environment setting that I might have missed?
Re: Error in my component for Hello World
It depends on what you want to do. In your code JApplicationHelper was required for the getPath method. You can see here the methods of JApplicationHelper:judyksp wrote:Do I have to import any functions that I need or is this an environment setting that I might have missed?
http://dev.joomla.org/component/option, ... ionhelper/
Gergo Erdosi