Welcome, Guest
Username: Password: Remember me

TOPIC: Add link to another component in cpanel

Add link to another component in cpanel 04 Jul 2014 13:33 #12502

  • cefnllys
  • cefnllys's Avatar
  • Offline
  • Premium Member
  • Posts: 102
  • Thank you received: 5
  • Karma: 1
Ok, so I have created two components that work independently but also have the ability to reference each other and use data from one another. I would like to set up a link between each of the components control panel and currently I am checking the database to see if a certain table is present if it is add another link.

I can get an extra link to display but i don't know how to make it link to another component, here is my code so far.

File: administrator/components/com_mycomponent/helpers/helper.php
switch($alias)
{
	case 'cpanel':
	case 'menu':
	default:
		$links = array(
			'admin.customers.default',
			'admin.venues.default',
			'admin.riskassesment.default',
			'admin.events.default',
			'admin.floorplans.default',
			'admin.eventmenus.default'
		);
						
		$tables = JFactory::getDbo()->getTableList();
		$mainframe = JFactory::getApplication();
		$prefix = $mainframe->getCfg('dbprefix');
		
		if(in_array($prefix.'serveit_mealcategories', $tables)) {
			array_push($links, 'com_serveit.default');
		}
								
		if ($alias != 'cpanel')
			array_unshift($links, 'admin.cpanel');
					
		break;
		}

so I just need to know how to create a link to the control panel of my other component,

Thanks in advance.
The administrator has disabled public write access.

Add link to another component in cpanel 07 Jul 2014 08:47 #12506

  • cefnllys
  • cefnllys's Avatar
  • Offline
  • Premium Member
  • Posts: 102
  • Thank you received: 5
  • Karma: 1
Anyone got any ideas?
The administrator has disabled public write access.

Add link to another component in cpanel 16 Jul 2014 12:59 #12513

  • cefnllys
  • cefnllys's Avatar
  • Offline
  • Premium Member
  • Posts: 102
  • Thank you received: 5
  • Karma: 1
I still haven't worked this out don't suppose anyones got any smart ideas I can try?
The administrator has disabled public write access.

Add link to another component in cpanel 22 Jul 2014 10:51 #12516

  • Romkabouter
  • Romkabouter's Avatar
  • Offline
  • Elite Member
  • Posts: 310
  • Thank you received: 131
  • Karma: 48
There is in the helper.php a function called "getMenuItems"

You should add:

$items = array(
'label' => 'My Label',
'view' => 'default',
'icon' => 'icon',
'extension' => 'com_serveit'
);
icon should be something available in your component
Fork it if you do not want it overwritten with a new version of your component ;)
aka: copy
administrator/components/com_mycomponent/_fork/helpers/helper.php
to
administrator/components/com_mycomponent/fork/helpers/helper.php

and add the functions you changed, I hope you understand how the forking works :)

Good luck :)
The administrator has disabled public write access.
The following user(s) said Thank You: admin, cefnllys

Add link to another component in cpanel 23 Jul 2014 14:43 #12521

  • cefnllys
  • cefnllys's Avatar
  • Offline
  • Premium Member
  • Posts: 102
  • Thank you received: 5
  • Karma: 1
Awsome! Thank you very much!
That has indeed enabled me to do what I wanted, and thankfully it wasn't too hard to implement

Thank you Romkabouter
The administrator has disabled public write access.

Add link to another component in cpanel 26 Jul 2014 11:21 #12541

  • admin
  • admin's Avatar
  • Online
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
In future, the menus will be handlable in XML special files.
For the moment many customs are localized in the helper.php

Thank you very much Romkabouter
K++;
Coding is now a piece of cake
The administrator has disabled public write access.
Time to create page: 0.103 seconds

Get Started