0

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 folder are 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);

   }
}

I have the file in the same directory as joomlabook.html.php. In this file I have the Class containing the method to view the results that I have retrieved from the joomlabook.php file.

Such as:

  <?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 get the error:

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

This occurs on the getPath() call. Can anybody tell me why?

2 Answers 2

0

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

JApplicationHelper::getPath('html')

For reference you can look here: JApplicationHelper::getPath

-1

JApplicationHelper is now deprecated in J3.0

require_once(JApplicationHelper::getPath('admin_html'));

Seems to work with:

for administrator

require_once(JPATH_COMPONENT.DIRECTORY_SEPARATOR.'admin'.DIRECTORY_SEPARATOR.'admin.html.php');

for frontend

      require_once(JPATH_COMPONENT.DIRECTORY_SEPARATOR.'admin.html.php');

rename your file admin.componentname.php to componentname.php

above steps make non MVC components to run in J3.x

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.