Page 1 of 1

Error in my component for Hello World

Posted: Tue Mar 18, 2008 9:44 am
by judyksp
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?

Re: Error in my component for Hello World

Posted: Wed Mar 19, 2008 7:49 pm
by erdsiger
Welcome to the forum!

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;
}
?>

Re: Error in my component for Hello World

Posted: Thu Mar 20, 2008 6:22 am
by judyksp
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?

Re: Error in my component for Hello World

Posted: Thu Mar 20, 2008 7:32 pm
by erdsiger
judyksp wrote:Do I have to import any functions that I need or is this an environment setting that I might have missed?
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:
http://dev.joomla.org/component/option, ... ionhelper/