Saffrongeek’s Diarylog
…..memoirs moments opened…

Joomla Backend toolbar in Frontend Form View

Did you ever felt to have a frontend form and make use of backend button and styles. Here is a simple way:

Step 1. Create a folder ‘helpers’ in the /adminisrator/components/com_yourcomponent

Step2. Create a file toolbar.php and below is a sample content.

<?php
defined(‘_JEXEC’) or die(‘Restricted access’);
jimport(‘joomla.html.toolbar’);

class YourcomponentnameHelperToolbar extends JObject
{
function componentnameToolbar() {
$bar =& new JToolBar( ‘Campaign Toolbar’ );
$bar->appendButton( ‘Standard’, ’save’, ‘Save’, ’savecomponentnametask’, false );
$bar->appendButton( ‘Separator’ );
$bar->appendButton( ‘Standard’, ‘cancel’, ‘Cancel’, ‘cancelcomponenttask’, false );
return $bar->render();
}

}

Step 3. Frontend mainfile(/component/com_yourcomponentname/yourcomponentname.php) should have below line added first.

require_once( JPATH_COMPONENT_ADMINISTRATOR.DS.’helpers’.DS.’toolbar.php’ );

Step 4.In the view logic, add to the form below codebase

echo YourcomponentnameHelperToolbar::componentnameToolbar();
JHTML::_(’script’, ‘joomla.javascript.js’, ‘includes/js/’);

// stylesheet from admin template
$document    = & JFactory::getDocument();
$document->addStyleSheet(‘administrator/templates/system/css/system.css’);
$document->addStyleSheet(‘administrator/templates/khepri/css/template.css’);
$document->addStyleSheet(‘administrator/templates/khepri/css/rounded.css’);

——–

Yep! That is it! You have the backend buttons and styling for frontend as well.

No Responses Yet to “Joomla Backend toolbar in Frontend Form View”

Leave a Reply