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.

Advertisements

2 Responses to “Joomla Backend toolbar in Frontend Form View”

  1. Hi,
    I don’t understand the step 4: in what page I should add the code?
    Thank you 😉

  2. Joomla CMS,Suchmaschinen-Optimierung, Webseiten schweiz,Magento shop, Online Shop, Webhosting,Homepage Redesign, e-commerce lösung, Homepage, Internetseiten, GoogleAdwords…

    […]Joomla Backend toolbar in Frontend Form View « Saffrongeek’s Diarylog[…]…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: