Page 1 of 1
JToolBarHelper()
Posted: Wed Sep 19, 2007 10:11 am
by motd
Hi all,
I'm getting the following error in my component:
Fatal error: Undefined class name 'jtoolbarhelper' in /Applications/MAMP/htdocs/components/com_suggestions/toolbars/toolbars.html.php on line 8
And here's toolbars.html.php:
Code: Select all
<?php
defined('_JEXEC') or die("Restricted Access");
class TOOLBAR
{
function _NEW()
{
JToolBarHelper::save();
JToolBarHelper::cancel();
}
function _DEFAULT()
{
$this->_NEW();
}
}
?>
Any idea what I am doing wrong?
Thanks!
Re: JToolBarHelper()
Posted: Wed Sep 19, 2007 1:02 pm
by ianmac
JToolBarHelper is only available from the administrator application.
Ian
Re: JToolBarHelper()
Posted: Fri Sep 21, 2007 7:29 am
by Mnu
ianmac wrote:JToolBarHelper is only available from the administrator application.
Ian
Is there a way to use JToolBarHelper and JSubMenuHelper in the front-end interface ? In fact, I have the same issue. It would be a shame if I had do the job again... My component needs exactly those functions... Add, Save, etc...
Maybe there is something in the API but I haven't found yet... Or should I write a derivated class from JToolBarHelper to adapt it to the front end interface ?
Can you help me ?
Thanx
Re: JToolBarHelper()
Posted: Fri Sep 21, 2007 11:12 am
by ianmac
Well, I'm sure it wouldn't be that difficult to implement those in the frontend. The biggest issue is that most of the styles are defined in the backend template.
I would take a look at the file administrator/include/toolbar.php and look at implemented something similar. Note there is other JavaScript that this relies on that may not be there in the frontend.
Really, you are probably better off using the JToolBar class, creating an object and adding buttons to it. You can see the API ref for more info.
Ian
Re: JToolBarHelper()
Posted: Mon Sep 24, 2007 1:29 pm
by Mnu
Thank you for your help...
Well, I think I'll write something new. I dont' need all the functions of JToolBar... I guess that will be easier for me to do. I'll have a look in the API and hope I'll manage to do something cool...
Mnu
Re: JToolBarHelper()
Posted: Mon Sep 24, 2007 2:43 pm
by ianmac
Take a look at:
http://dev.joomla.org/component/option, ... :jtoolbar/where you'll find this example:
$bar =& new JToolBar( 'My ToolBar' );
$bar->appendButton( 'Separator' );
$bar->appendButton( 'Standard', 'send', 'Activate', 'activate', false );
$bar->prependButton( 'Popup', 'new', 'Popup Test', 'http://www.joomla.org', 300, 300, 150, 150 );
echo $bar->render();
See the file:
administrator/templates/khepri/css/icon.css for the styling. It really isn't that difficult, and I'm sorry if I made it seem that way.
Ian
Re: JToolBarHelper()
Posted: Sat Oct 06, 2007 10:39 pm
by NotionCommotion
I was able to append a button, however, couldn't figure out to associate a given class with the botton, or change it to a graphical button instead of just text. Any help would be apprecated! Thanks
Re: JToolBarHelper()
Posted: Sun Oct 07, 2007 11:00 am
by Mnu
Thank you for this, Ian !
I just have to find how to render this toolbar with icons... I'll have a look on this later...
Re: JToolBarHelper()
Posted: Sun Oct 07, 2007 2:51 pm
by NotionCommotion
Mnu, Good luck with your efforts, and please post any success you may I so I may also learn from it. Thanks
Re: JToolBarHelper()
Posted: Mon Oct 08, 2007 1:20 pm
by cgiguere
ianmac wrote:JToolBarHelper is only available from the administrator application.
Ian
Ian,
Trying to do same example as p18-19-20 from book "Learning Joomla! 1.5 Extension Development" but getting fatal error from the back end as click on Components/Restaurant Reviews:
Fatal error: Class 'JToolBarHelper' not found in (myLocalhost)\administrator\components\com_reviews\toolbar.reviews.html.php on line 16
Can u help please? Here is the toolbar.reviews.html.php file:
defined ('_JEXEC') or die('Restricted access');
//create a new class for the new toolbar
class TOOLBAR_reviews {
function _NEW (){
JToolBarHelper::save();
JToolBarHelper::apply();
JToolBarHelper::annul();
}//end function _NEW()
function _DEFAULT() {
JToolBarHelper::title( JText::_( 'Restaurant Reviews' ),'generic.png' );
JToolBarHelper::publishList();
JToolBarHelper::unpublishList();
JToolBarHelper::editList();
JToolBarHelper::deleteList();
JToolBarHelper::addNew();
}//end function _DEFAULT()
}//end class
?>
Re: JToolBarHelper()
Posted: Tue Oct 09, 2007 1:24 pm
by NotionCommotion
Maybe add:
jimport( 'joomla.application.component.view' );
Sometimes, it appears that the class has already been added by the overall Joomla! code, and other times you need to do it manually, but I am not really sure...
Re: JToolBarHelper()
Posted: Tue Oct 09, 2007 1:33 pm
by AmyStephen
NotionCommontion -
The way it was explained to me is roughly like this.
JToolBar is part of the framework and describes the toolbar buttons.
JToolBarHelper is part of the CMS that sits on top of and utilizes the framework. The JToolBar class is defined in
/administrator/includes/toolbar.php. It deals specifically with the CMS toolbar buttons.
The
API reference only covers the Framework, not the CMS.
So, your solution makes sense - it's importing a class from the CMS - the application - not the framework.
Take what I say very cautiously as I am early buds of learning.
Thanks!
Amy
Re: JToolBarHelper()
Posted: Tue Oct 09, 2007 3:06 pm
by cgiguere
Tks Amy and NotionCommotion,
I have tried your recommendation. I am just starting with PHP and Joomla. In Java, the import namespace is usually placed above the file, outside of the class definition. Do I do the same in PHP?
If so, just tried it, and I still get the fatal error. If not, where should I place the import statement? Sorry for the simplicity of my question but I am in the process of learning.
Interesting is the following: If I use another class (example JMenuBar) instead of JToolBarHelper, all works fine. I do see my toolbar. I am using Joomla 1.5 beta, and the XAMPP bundel (PHP 5.2.3). Could it have to do with the Joomla built I am using?
tks guys! Very good and helpful forum,
Christiane
Re: JToolBarHelper()
Posted: Tue Oct 09, 2007 5:56 pm
by ianmac
If you are using a beta, you really should upgrade - we are many releases past that, and much has changed. JToolBarHelper might have come after beta, I'm not sure.
PHP doesn't have namespaces (at least not until more recent versions). jimport is only a Joomla! function that is used to require a file. Files and be included/required any where - it doesn't matter where.
Ian
Re: JToolBarHelper()
Posted: Tue Oct 09, 2007 7:26 pm
by cgiguere
Ian,
Indeed, I am using Joomla! 1.5.0 Beta [ Khepri ] 12-Oct-2006 00:00 GMT version. The problem may stem from there. I will upgrade, as advised. Your explanation on where to put the Jimport() is very clear. Let me try to upgrade and see if I get further.
Many tks,
Christiane
Re: JToolBarHelper()
Posted: Tue Oct 09, 2007 9:52 pm
by ianmac
Yeah... Beta is coming on a year old now... If you develop to it you are bound to run into trouble when trying it on 1.5 RC3 or stable.
Ian
Re: JToolBarHelper()
Posted: Thu Oct 11, 2007 5:31 am
by NotionCommotion
"framework"?
"cms"?
Pardon my ignorance, but can you describe what these are and how they pertain to a joomla extention?
Thanks
Re: JToolBarHelper()
Posted: Thu Oct 11, 2007 3:29 pm
by AmyStephen
Re: JToolBarHelper()
Posted: Thu Oct 11, 2007 6:43 pm
by ianmac
Well, to clarify...
Joomla! 1.5 has a completely redeveloped framework API. This framework makes many tasks simpler for PHP developers - i.e. working with files, interacting with an ftp server, working with arrays, managing sessions, HTML forms, internationalization, database access, user tracking, dates, event handling, caching and more. This is the Joomla! framework.
For a diagram, see:
http://dev.joomla.org/content/view/1137/80/Applications are built on top of the framework. The three applications you are probably most familiar with are the site application and the administration application. The former is what site visitors most often see, and the latter is what site administrators use to manage the site.
In general, the framework API is available no matter what application you are using, though there are still some classes that need special work to use in the frontend or backend (i.e. they are specific to one or the other).
Each application has some classes and infrastructure in addition to the framework. JToolBarHelper is one such class. But really, it is just a helper class that interacts with the framework JToolBar class allowing components to interact with the administrator toolbar.
The framework classes are all found under /libraries/joomla. The application classes are found in other directories.
Ian
Re: JToolBarHelper()
Posted: Thu Oct 18, 2007 4:29 pm
by cgiguere
Notion, Amy, Jan,
Still getting the previously mentioned fatal error while using the JToolBarHelper class (used for a back end component). Meantime, have added the jimport statement as recommended by Notion and upgraded to RC3 (I was working with beta version).
I was still looking for an answer until I read this:
http://joomlacode.org/gf/project/iansto ... em_id=4807If I understood wel, JToolBarHelper would has a bug becaue JmenuBar was renamed JToolBarHelper in april 2007. The developer says that it gives an error msg. He checked the file out (and presumably is fixing the bug). This was in june 2007. Is my problem perhaps caused by the renaming? When I use JMenuBar class it gives me no problem.
Tks in advance
Re: JToolBarHelper()
Posted: Thu Oct 18, 2007 4:47 pm
by ianmac
Hey...
As I said, upgrade to a newer release... JMenuBar was renamed to JToolBarHelper.
If you are planning on only using your component on that one install that you have and you never plan on upgrading past the beta, then continue to use JMenuBar.
If you plan on releasing your component to be used by somebody else, or if you plan on using a version of 1.5 later than the beta (which is strongly recommended because security holes have been found in the beta during security profiling), then I would upgrade to at least RC3 as soon as possible and start developing for it. Otherwise, you are asking for headaches later.
The bug that you referenced on my project on joomlacode was exactly as you described. The bug should be fixed by now in that project.
Ian