Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

Changing menu on CPanel?? 03 Aug 2016 06:38 #14353

If I wanted to add more items and change the links on the CPanel in my components, where would I do this? Sorry had a good look but have drawn a blank..

Please Log in or Create an account to join the conversation.

Changing menu on CPanel?? 03 Aug 2016 09:32 #14354

You should fork the admin/component/helper/helper.php.

There you will find "addSubmenu", where you can change the links array.
After that, you will have to change getMenuItems, where you can further specify the link
The following user(s) said Thank You: admin

Please Log in or Create an account to join the conversation.

Changing menu on CPanel?? 03 Aug 2016 09:56 #14355

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
First step, you create all the available pages items.
Second step, you define which link is called for the menu. You can create different menus.

Well, this part is ugly. I was waiting something coming from Joomla, but I don't see any move at the moment.
When you talk about this, I feel in a shame when I see how is the code. Not so bad, but really redondant.
I would like to rewrite it all, using xml files for that.

Good luck.
Coding is now a piece of cake

Please Log in or Create an account to join the conversation.

Changing menu on CPanel?? 03 Aug 2016 22:23 #14356

Thanks, I will go and have a look at the helper file and fork it. Will see how I go. Thanks both...

Please Log in or Create an account to join the conversation.

Changing menu on CPanel?? 04 Aug 2016 12:56 #14360

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
I think the new way for building menus based on XML file will be available soon because it is easy to do and because I feel so bad every time I see the current code. I get a headache every time... lol.
Coding is now a piece of cake

Please Log in or Create an account to join the conversation.

Changing menu on CPanel?? 09 Aug 2016 08:31 #14393

  • liubov
  • liubov's Avatar
  • Offline
  • Elite Member
  • Elite Member
  • (=) 10 mn and it's ready!
  • Posts: 279
  • Thank you received: 36

Romkabouter wrote: You should fork the admin/component/helper/helper.php.

There you will find "addSubmenu", where you can change the links array.
After that, you will have to change getMenuItems, where you can further specify the link


I tried to fork the helper to do that without success for the moment. I write here what i've done step by step:
- I want to delete 'Positions' Menus -
  1. Create admin/fork directory
  2. Copy the admin/_fork/helper.php in admin/fork/
  3. Adding administration <folder>fork</folder> in mycomponent.xml
  4. Delete the memu in mycomponent.xml i do not want to see in Components/mycomponent/submenus
  5. Copy original function 'addSubmenu' in admin/fork/helper.php
  6. Delete the menu i do not want to see in the Admin Cpanel
    $links = array(
    'admin.pedigrees.default',
    'admin.etalons.default',
    'admin.lices.default',
    'admin.portees.default',
    'admin.actualites.default',
    /* 'admin.positions.default', */
    'admin.races.default',
    'admin.robes.default',
    'admin.yeuxs.default',
    'admin.annees.default',
    'admin.rubriques.default'
    );
  7. Copy original function 'getMenuItems' in admin/fork/helper.php
  8. Delete the Menu Item i do not want to see in the Admin Cpanel
    /* $items = array(
    'label' => 'JBREEDING_LAYOUT_GESTION_DES_POSITIONS',
    'view' => 'positions',
    'layout' => 'default',
    'icon' => 'jbreeding_positions'
    ); */

Forked helper do not overwrite the original function because i still see the Item Menu that i've deleted.


( or may be we can overwrite but not cancel/delete objects as xml forms ) ?

Please Log in or Create an account to join the conversation.

Last edit: by liubov.

Changing menu on CPanel?? 09 Aug 2016 09:52 #14395

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
Here is the solution.
public static function addSubmenu($view, $layout, $alias = 'menu')
{
	$items = static::getMenuItems();

	$client = 'admin';
	if (JFactory::getApplication()->isSite())
		$client = 'site';

	$links = array();
	switch($client)
	{
		case 'admin':
			switch($alias)
			{
				case 'cpanel':
				case 'menu':
				default:
					$links = array(
					
					
// ->   Change order, add/remove items HERE

						'admin.continents.default',
						'admin.countries.default',
						'admin.travellers.default',
						'admin.visits.visitstravellers',
						'admin.visits.visitscities',
						'admin.visits.default',
						'admin.cities.default'
					);

					if ($alias != 'cpanel')
						array_unshift($links, 'admin.cpanel');

					break;
			}
			break;
...

The items are prepared in getMenuItems()
Coding is now a piece of cake

Please Log in or Create an account to join the conversation.

Last edit: by admin.

Changing menu on CPanel?? 09 Aug 2016 10:27 #14400

  • liubov
  • liubov's Avatar
  • Offline
  • Elite Member
  • Elite Member
  • (=) 10 mn and it's ready!
  • Posts: 279
  • Thank you received: 36
It is exactely what i ve done :
public static function addSubmenu($view, $layout, $alias = 'menu')
	{
		$items = static::getMenuItems();

		// Will be handled in XML in future (or/and with the Joomla native menus)
		// -> give your opinion on j-cook.pro/forum


		$client = 'admin';
		if (JFactory::getApplication()->isSite())
			$client = 'site';

		$links = array();
		switch($client)
		{
			case 'admin':
				switch($alias)
				{
					case 'cpanel':
					case 'menu':
					default:
						$links = array(
							'admin.pedigrees.default',
							'admin.etalons.default',
							'admin.lices.default',
							'admin.portees.default',
							'admin.actualites.default',
            /*===>	'admin.statuts.default',   <===*/
							'admin.races.default',
							'admin.robes.default',
							'admin.yeuxs.default',
							'admin.annees.default',
							'admin.rubriques.default'
						);

and for the forked GetMenuItems :
public static function getMenuItems()
	{
		// Will be handled in XML in future (or/and with the Joomla native menus)
		// -> give your opinion on j-cook.pro/forum

		$items = array();

		$items['admin.pedigrees.default'] = array(
			'label' => 'JBREEDING_LAYOUT_GESTION_DES_CHIENS',
			'view' => 'pedigrees',
			'layout' => 'default',
			'icon' => 'jbreeding_pedigrees'
		);

		$items['admin.etalons.default'] = array(
			'label' => 'JBREEDING_LAYOUT_GESTION_DES_ETALONS',
			'view' => 'etalons',
			'layout' => 'default',
			'icon' => 'jbreeding_etalons'
		);

		$items['admin.lices.default'] = array(
			'label' => 'JBREEDING_LAYOUT_GESTION_DES_LICES',
			'view' => 'lices',
			'layout' => 'default',
			'icon' => 'jbreeding_lices'
		);

		$items['admin.portees.default'] = array(
			'label' => 'JBREEDING_LAYOUT_GESTION_DES_PORTEES',
			'view' => 'portees',
			'layout' => 'default',
			'icon' => 'jbreeding_portees'
		);

		$items['admin.actualites.default'] = array(
			'label' => 'JBREEDING_LAYOUT_GESTION_DES_ACTUALITES',
			'view' => 'actualites',
			'layout' => 'default',
			'icon' => 'jbreeding_actualites'
		);

    /*===> $items['admin.statuts.default'] = array(
			'label' => 'JBREEDING_LAYOUT_GESTION_DES_POSITIONS',
			'view' => 'statuts',
			'layout' => 'default',
			'icon' => 'jbreeding_statuts'
		); <===*/

		$items['admin.races.default'] = array(
			'label' => 'JBREEDING_LAYOUT_GESTION_DES_RACES',
			'view' => 'races',
			'layout' => 'default',
			'icon' => 'jbreeding_races'
		);

..... .... .... ....

Please Log in or Create an account to join the conversation.

Changing menu on CPanel?? 09 Aug 2016 10:36 #14402

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
If you only need to remove the item, you don't need to fork getMenuItems().

I downloaded your component and made the operation. It works like a charm.
You might have missed something.

What happen if you comment the line in the original helper ?
It is working, check very well if you are not doing another mistake.
Coding is now a piece of cake

Please Log in or Create an account to join the conversation.

Changing menu on CPanel?? 09 Aug 2016 11:26 #14404

  • liubov
  • liubov's Avatar
  • Offline
  • Elite Member
  • Elite Member
  • (=) 10 mn and it's ready!
  • Posts: 279
  • Thank you received: 36
Arg ! ok, I will check with better eyes :)

I guess my forked helper is not loaded ...

j-cook source with modified fork helper here : com_jbreeding_beta_3.0.1.zip

just to validate the structure if you have some time ;p

Please Log in or Create an account to join the conversation.

Last edit: by liubov.

Changing menu on CPanel?? 09 Aug 2016 13:22 #14406

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
put your file in 'fork/helpers/helper.php'
Coding is now a piece of cake
The following user(s) said Thank You: liubov

Please Log in or Create an account to join the conversation.

Changing menu on CPanel?? 09 Aug 2016 13:58 #14408

  • liubov
  • liubov's Avatar
  • Offline
  • Elite Member
  • Elite Member
  • (=) 10 mn and it's ready!
  • Posts: 279
  • Thank you received: 36
I tell you that I had to change my eyes !

Thanks a lot for this missing directory.
works fine now.

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Time to create page: 0.077 seconds

Awards for the best Joomla app. This product is gonna win an award for this amazing job. Cook Self Service is the the best application from all over the Joomla universe ! It brings Joomla to a professional level really advanced for developers. It is a real fun to develop with it. The ACL part and security checks implementation are just... so much hours saved. I can now concentrate myself more on the design part and the creative works. Thank you so much. Guys I offer you all my congratulation ! Keep up the works because Joomla is needing it to increase the quality of extensions availables on the JED. I also learned a lot because I can see how to code at the proper place and I found all my answers reading the forum.
lack_hanson (JED)
          

Get Started