Error in my component for Hello World

Have a programming question regarding your component, plug-in, extension or core hacks? Have an interesting tidbit, FAQ or programming tip you’d like to share? This is the place for you.

Moderators: tjay, seadap, Rogue4ngel, matthewhayashida

Post Reply
judyksp
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Mon Mar 17, 2008 2:20 pm

Error in my component for Hello World

Post by judyksp » Tue Mar 18, 2008 9:44 am

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?

erdsiger
Joomla! Intern
Joomla! Intern
Posts: 72
Joined: Sat Nov 11, 2006 9:34 pm
Location: Hungary

Re: Error in my component for Hello World

Post by erdsiger » Wed Mar 19, 2008 7:49 pm

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

judyksp
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Mon Mar 17, 2008 2:20 pm

Re: Error in my component for Hello World

Post by judyksp » Thu Mar 20, 2008 6:22 am

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?

erdsiger
Joomla! Intern
Joomla! Intern
Posts: 72
Joined: Sat Nov 11, 2006 9:34 pm
Location: Hungary

Re: Error in my component for Hello World

Post by erdsiger » Thu Mar 20, 2008 7:32 pm

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/
Gergo Erdosi


Post Reply