Welcome, Guest
Username: Password: Remember me

TOPIC: Joomla Admin style Control Panel for JCook

Joomla Admin style Control Panel for JCook 17 Sep 2012 21:52 #3722

  • MorganL
  • MorganL's Avatar
  • Offline
  • Platinum Member
  • Posts: 438
  • Thank you received: 53
  • Karma: 15
1) Download, and extract your component from JCook (refered to as main files)

2) Download these files, and extract (refered to as cp files)

3) Using your editor do the following on the cp files, I use dreamweaver and search the entire folder, you may need to just check each file individually.. There aren't many.

Do a CASE SENSITIVE find and replace of the string "Yourcomponent" with the name of your component. Capitalise the first letter. Should be six changes made
Do a CASE SENSITIVE find and replace of the string "com_yourcomponent" with the name of your component. Remember the com_ . The should be 2 changes made
Do a CASE SENSITIVE find and replace of the string "YOURCOMPONENT_" with the name of your component. Remember the capitals and the ending _ , there should be 3 changes made
Rename the 16 pixel image icon-16-yourcomponent_controlpanelmain to icon-16-(your_component_name)_controlpanelmain (without the quotes)
Rename the 48 pixel image icon-48-yourcomponent_controlpanelmain to icon-48-(your_component_name)_controlpanelmain (without the quotes)

4) Cut the controlpanelmain folder from views and paste into the admin/views folder of the main files

5) Cut the controlpanelmain.php from controllers and paste into the admin/controllers folder of the main files

6) Cut the image from the images folder and paste into the admin/images folder of the main files.

You can now get rid of the empty folders from the downloaded files and start working on your installer package

The following steps are done on the main files extracted from your component

7) Open the folder containing the main files, and open admin/css/(your_component_name).css

8) Add the following to the end of the css file
/* Control panel css code begins */
.cpanel-right {
	color: #777;
}
/* Control panel css code ends */

then save and close it

9) Open up the admin/helpers/helper.php files and add the following at the beginning, after ther first set of notes (shown in the snippet)

/*
	 * Recreate the URL with a redirect in order to :
	 * 	-> keep an good SEF
	 *  -> always kill the post
	 *  -> precisely control the request
	 */
	 

	 /* Control panel icons start */
	public function controlpanelIcons( $link, $image, $text ) {
		
		$lang	= &JFactory::getLanguage();
		$button = '';
		$button .= '<div class="icon-wrapper">';
		$button .=	'<div class="icon">'
				   .'<a href="'.$link.'">'
				   .JHTML::_('image.site',  $image, '/components/com_yourcomponet/images/', NULL, NULL, $text )
				   .'<span>'.$text.'</span></a>'
				   .'</div>';
		$button .= '</div>';

		return $button;
	}
	 /* Control panel icons end */


10) Edit toolbar.css to include
.icon-48-(your_component_name)_controlpanelmain 		{ background-image: url('../images/icon-48-(your_component_name)_controlpanelmain.png'); }

11) In the code you just pasted, alter com_yourcomponent_name (twice) in the line to the name of your component.

12) Edit the main controller for the component in the root of the admin folder (usually yourcomponent.php) and add the following

case 'controlpanelmain' :

        	$controllerName = "controlpanelmain";

		break;


after the
switch ($view)
		{

part of the code


13) Edit the main controller (same file) to include
JSubMenuHelper::addEntry(JText::_("YOURCOMPONENT_VIEW_CONTROLPANELMAIN"), 'index.php?option=com_yourcomponent&view=controlpanelmain', ($view == 'controlpanelmain'));

after the code line

if ($mainMenu)
{

and change YOURCOMPONENT to the name of your component, in capitals

14) Alter the following code (same file), normally near the very end of the controller file you are already editting
default:
			$view = '-something-';
			$layout = 'default';

to
default:
			$view = 'controlpanelmain';
			$layout = 'default';


then save and close the main controller

15) Edit the en-GB.com_yourcomponent.sys.ini by adding
YOURCOMPONENT_MENU_CONTROLPANELMAIN="Control Panel"

(remember to replace YOURCOMPONENT with the appropriate string, as seen throughout the rest of the language file)

16) Edit the en-GB.com_yourcomponent.ini by adding
YOURCOMPONENT_LAYOUT_CONTROLPANELMAIN="Control Panel" 
YOURCOMPONENT_VIEW_CONTROLPANELMAIN="Control Panel"


(remember to replace YOURCOMPONENT with the appropriate string (name of your component), as seen throughout the rest of the language file)



17) Open admin/views/controlpanelmain/tmpl/default.php file

There are two ways of completing the buttons.. dynamic, or the much easier manual way..

You now need to be a bit sneaky to get the dynamic code to work. JCook tends to put underscores as spaces in the language files.. Hence we need to get a list of controllers we want to turn into buttons on our control panel and make them UPPERCASE and turn spaces to _..

example files
Table, controller, language translation

Branch = branch = COMPONENT_VIEW_BRANCH
Branch Locations = branchlocations = COMPONENT_VIEW_BRANCH_LOCATIONS
Branch Staff = branchstaff = COMPONENT_VIEW_BRANCH_STAFF

We need to get the controller name based on the bit at the end of the above examples and paste them into the line (17) like so
$controllers = explode(',', 'BRANCH,BRANCH_LOCATIONS,BRANCH_STAFF');

this section can go a bit wrong depending on your naming convention, but tweaking the language files can solve the problem,

Alternativly, you can ditch the loop, and make buttons manually
<?php
			$link = 'index.php?option=com_yourcomponent&view=controlpanelmain';
			echo YourcomponentHelper::controlpanelIcons( $link, 'icon-48-yourcomponent_controlpanelmain.png', JText::_( 'YOURCOMPONENT_VIEW_CONTROLPANELMAIN' ) );
		?>

		<?php
			$link = 'index.php?option=com_yourcomponent&view=branch';
			echo YourcomponentHelper::controlpanelIcons( $link, 'icon-48-yourcomponent_branch.png', JText::_( 'YOURCOMPONENT_VIEW_BRANCH' ) );
		?>

Remember to change ALL relevant information in the buttons.. the component name, the controllers to your components information.

All files have now been modified, you can now zip up the work and install to joomla

By just duplicating the process, and naming the relevant parts / code to controlpanelwhatever.. you can create multiple control panels to break your controllers into manageable sections.

Once this bit of work has been duplicated and confirmed as working, I will post up code for accordians at the right hand side.
Morgan Leecy MCSE

Novell / Linux
PHP. MYSQL, Apache, node.js
Coldfusion, JQuery, HTML5
Joomla
Last Edit: 23 Sep 2012 16:45 by MorganL. Reason: Minor mistakes on altering main controller
The administrator has disabled public write access.
The following user(s) said Thank You: twev, VeCrea, Tomaselli, edwardcox, JoomGuy, dyvel
Time to create page: 0.069 seconds

Get Started