-
jonathanbell
-
Topic Author
-
Offline
-
Premium Member
-
-
Posts: 147
-
Thank you received: 5
-
-
-
-
|
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.
|
-
Romkabouter
-
-
Offline
-
Elite Member
-
-
Posts: 310
-
Thank you received: 131
-
-
-
-
-
|
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.
|
-
admin
-
-
Offline
-
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.
|
-
jonathanbell
-
Topic Author
-
Offline
-
Premium Member
-
-
Posts: 147
-
Thank you received: 5
-
-
-
-
|
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.
|
-
admin
-
-
Offline
-
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.
|
-
liubov
-
-
Offline
-
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 -
- Create admin/fork directory
- Copy the admin/_fork/helper.php in admin/fork/
- Adding administration <folder>fork</folder> in mycomponent.xml
- Delete the memu in mycomponent.xml i do not want to see in Components/mycomponent/submenus
- Copy original function 'addSubmenu' in admin/fork/helper.php
- 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'
);
- Copy original function 'getMenuItems' in admin/fork/helper.php
- 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.
|
-
admin
-
-
Offline
-
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.
|
-
liubov
-
-
Offline
-
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.
|
-
admin
-
-
Offline
-
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.
|
-
liubov
-
-
Offline
-
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.
|
-
admin
-
-
Offline
-
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.
|
-
liubov
-
-
Offline
-
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.
|
Time to create page: 0.077 seconds
|