A bit explanation about Joomla Helper : JToolBarHelper

October 4th, 2011 Posted in CMS, Joomla, PHP

recently i used this joomla helper : JToolBarHelper class when i need to add a button, i need a button which is linked to an add form, and found this class after googling for a while. some example how to use this class ,  this time i use addNew function on JToolBarHelper class :

// will create an add button
JToolBarHelper::addNew( $task = 'add', $alt = 'Tambah Data Guru' );

function above will create an add button with onclick javascript action :

onclick="javascript: submitbutton('add')"

so we should create a javascript function like this :

<script type="text/javascript">;
function submitbutton()
{
document.location.href="<?echo JURI::root() ?>administrator/index.php?option=com_sms&controller=guru&task=mytask";
}
</script>
JURI::root() 

is your joomla root Url. this way when you click your add button it will route to your custom component, controller and task.

More example how using JToolBarHelper class:

class implementJtolbarhelperViewimplementJtolbarhelper extends JView
{
function display($tpl = null) {
global $mainframe, $option;
JToolBarHelper::title( 'Hello Component', 'generic.png' );
JToolBarHelper::deleteList();
JToolBarHelper::editListX();
JToolBarHelper::addNewX();
JToolBarHelper::publishList();
JToolBarHelper::unpublishList();
JToolBarHelper::preferences('com_hello', '500');
}

Below Is complete Reference of JToolBarHelper class :

Defined in

administrator/includes/toolbar.php

Methods

Method name Description
title Creates the title cell
spacer Writes a spacer cell
divider Write a divider between menu buttons
custom Writes a custom option and task button for the button bar
customX Writes a custom option and task button for the button bar. Extended version of custom() calling hideMainMenu() before submitbutton().
preview Writes a preview button for a given option (opens a popup window)
help Writes a help button
back Writes a cancel button that will go back to the previous page without doing
media_manager Writes a media_manager button
addNew Writes the common ‘new’ icon for the button bar
addNewX Writes the common ‘new’ icon for the button bar. Extended version of addNew() calling hideMainMenu() before submitbutton().
publish Writes a common ‘publish’ button
publishList Writes a common ‘publish’ button for a list of records
makeDefault Writes a common ‘default’ button for a record
assign Writes a common ‘assign’ button for a record
unpublish Writes a common ‘unpublish’ button
unpublishList Writes a common ‘unpublish’ button for a list of records
archiveList Writes a common ‘archive’ button for a list of records
unarchiveList Writes an unarchive button for a list of records
editList Writes a common ‘edit’ button for a list of records
editListX Writes a common ‘edit’ button for a list of records. Extended version of editList() calling hideMainMenu() before submitbutton().
editHtml Writes a common ‘edit’ button for a template html
editHtmlX Writes a common ‘edit’ button for a template html.
editCss Writes a common ‘edit’ button for a template css
editCssX Writes a common ‘edit’ button for a template css. Extended version of editCss() calling hideMainMenu() before submitbutton().
deleteList Writes a common ‘delete’ button for a list of records
deleteListX Writes a common ‘delete’ button for a list of records. Extended version of deleteList() calling hideMainMenu() before submitbutton().
trash Write a trash button that will move items to Trash Manager
apply Writes an apply button for a given option. Apply operation leads to a save action only (does not leave edit mode)
save Writes a save button for a given option. Save operation leads to a save and then close action
cancel Writes a cancel button and invokes a cancel operation (eg a checkin)
preferences Writes a configuration button and invokes a cancel operation (eg a checkin)

recently i used this joomla helper : JToolBarHelper class when i need to add a button, i need a button which is linked to an add form, and found this class after googling for a while. some example how to use this class ,  this time i use addNew function on JToolBarHelper class :


// will create an add button
JToolBarHelper::addNew( $task = 'add', $alt = 'Tambah Data Guru' );

function above will create an add button with onclick javascript action :

onclick="javascript: submitbutton('add')"

so we should create a javascript function like this :

<script type="text/javascript">
function submitbutton()
{
document.location.href="<?echo       JURI::root()?>administrator/index.php?option=com_sms&controller=guru&task=mytask";
}
</script>

JURI::root() is your joomla root Url. this way when you click your add button it will route to your custom component, controller and task.

More example how using JToolBarHelper class:


class implementJtolbarhelperViewimplementJtolbarhelper extends JView
{
function display($tpl = null) {
global $mainframe, $option;
JToolBarHelper::title( 'Hello Component', 'generic.png' );
JToolBarHelper::deleteList();
JToolBarHelper::editListX();
JToolBarHelper::addNewX();
JToolBarHelper::publishList();
JToolBarHelper::unpublishList();
JToolBarHelper::preferences('com_hello', '500');
}

Below Is complete Reference of JToolBarHelper class :

Defined in

administrator/includes/toolbar.php

Methods

Method name Description
title Creates the title cell
spacer Writes a spacer cell
divider Write a divider between menu buttons
custom Writes a custom option and task button for the button bar
customX Writes a custom option and task button for the button bar. Extended version of custom() calling hideMainMenu() before submitbutton().
preview Writes a preview button for a given option (opens a popup window)
help Writes a help button
back Writes a cancel button that will go back to the previous page without doing
media_manager Writes a media_manager button
addNew Writes the common ‘new’ icon for the button bar
addNewX Writes the common ‘new’ icon for the button bar. Extended version of addNew() calling hideMainMenu() before submitbutton().
publish Writes a common ‘publish’ button
publishList Writes a common ‘publish’ button for a list of records
makeDefault Writes a common ‘default’ button for a record
assign Writes a common ‘assign’ button for a record
unpublish Writes a common ‘unpublish’ button
unpublishList Writes a common ‘unpublish’ button for a list of records
archiveList Writes a common ‘archive’ button for a list of records
unarchiveList Writes an unarchive button for a list of records
editList Writes a common ‘edit’ button for a list of records
editListX Writes a common ‘edit’ button for a list of records. Extended version of editList() calling hideMainMenu() before submitbutton().
editHtml Writes a common ‘edit’ button for a template html
editHtmlX Writes a common ‘edit’ button for a template html.
editCss Writes a common ‘edit’ button for a template css
editCssX Writes a common ‘edit’ button for a template css. Extended version of editCss() calling hideMainMenu() before submitbutton().
deleteList Writes a common ‘delete’ button for a list of records
deleteListX Writes a common ‘delete’ button for a list of records. Extended version of deleteList() calling hideMainMenu() before submitbutton().
trash Write a trash button that will move items to Trash Manager
apply Writes an apply button for a given option. Apply operation leads to a save action only (does not leave edit mode)
save Writes a save button for a given option. Save operation leads to a save and then close action
cancel Writes a cancel button and invokes a cancel operation (eg a checkin)
preferences Writes a configuration button and invokes a cancel operation (eg a checkin)

Leave a Reply

You must be logged in to post a comment.