tags:

views:

245

answers:

1

Hi,

I am very new to Joomla  and i started with a tutorial in creating a database and creating a componenet.

I have created a folder named com_joomlabook within that 2 files joomlabook.php

<?php

 defined( '_JEXEC' ) or die( 'Restricted access' );
  require_once (JApplicationHelper::getPath('joomlabook_html'));

  $document=&JFactory::getDocument();
 $document->setTitle('Example component Joomla! book');//set the page title 

switch(JRequest::getCmd('task'))
{

    case 'free':
      // more display possibilities
    break;
    default:
       JoomlabookController::listJoomlabook();
    break;

}


class JoomlabookController{

function listJoomlaBook(){
      $db    =& JFactory::getDBO();
      $db->setQuery('SELECT * from #_joomla_book');
      $rows = $db->loadObjectList();//get the results from the table
      Joomlabookdetails::view($rows);

  }}

and i am having a file in the same directory as joomlabook.html.php

where i am having the Class where i have the method to view the results that i have retrieved ffrom the joomlabook.php file

like

  <?php
   defined( '_JEXEC' ) or die( 'Restricted access' );


  class Joomlabookdetails
   {
    function view($rows)
     {
       foreach ($rows as $row) {
       echo $row->text;
     }
     }}

But when i run it in the browser using http://localhost/joomla/Joomla_1.5.7-Stable-Full_Package/administrator/index.php?option=com_joomlabook

i am getting the error as

Fatal error: require_once() [function.require]: Failed opening required '' (include_path='.:/usr/share/php:/usr/share/pear') in /home/ntdg/public_html/joomla/Joomla_1.5.7-Stable-Full_Package/administrator/components/com_joomlabook/joomlabook.php on line 6 that is in the getPath line why so??Please suggest me.

A: 

You just have to pass 'html' to JApplicationHelper::getPath, example:

JApplicationHelper::getPath('html')

For reference you can look here: JApplicationHelper::getPath

Cesar