Continuing on our journey of adding a global menu item, last week I covered how to pass data through to our custom menu option. However, I did so by simply copying over the core profileactions .hbt and .js file over to custom which leaves it vulnerable to being overwritten by some other add-on down the road. To minimize that risk I will now cover how to create a custom view that extends the core profileactions view.
Copy the Custom View
Copy these existing files:
- /custom/clients/base/views/profileactions/profileactions.hbt
- /custom/clients/base/views/profileactions/profileactions.js
- /custom/clients/base/views/wiki-profileactions/wiki-profileactions.hbt
- /custom/clients/base/views/wiki-profileactions/wiki-profileactions.js
The new wiki-profileactions.hbt will remain exactly like it was before where the whole menu will be defined. Ideally we would just have our single, new addition to the menu in this file, but that does not seem possible yet.
Extending a SugarCRM View
The big change will be with wiki-profileactions.js. Instead of redefining the whole profileactions view we will extend from the core view and simply invoke the parent in the method that we want to override:
Altering a Layout Definition
The final step is to tell the header layout to use the new wiki-profileactions view. Copy over /clients/base/layouts/header/header.php to /custom/clients/base/layouts/header/header.php and change the profileactions reference to wiki-profileactions:
Now run a Quick Repair & Rebuild (should be able to skip if you have developerMode turned on) then refresh the page. You should should then see your menu item as before, but now with a mostly safe way of coding it.
![](https://www.sugaroutfitters.com/assets/img/blog/sugarcrm7-global-menu-item/sugarcrm-7-custom-data-menu-.png)
Of course, the yet unsolved issue with this method is that now the header layout can be stomped out by anyone else. The code is safe, but it may no longer show if someone else touches header.php. I'd like to find a way to hook in and trigger a call to a build and add the additional menu item AFTER the core profileactions view (or any view for that matter) has loaded.
Anyone have any ideas?
-
Ambit Key Account Management (KAM)
FEATUREDAmbit Key Account Management (KAM) solution simplifies and brings value to the Account Planning and Account Management processes for your most important sales personnel – your Key Account Manage... -
User Activity Tracker
FEATUREDThis plugin provides insights into user activity within SugarCRM, giving you a clear view of how much time each user spends in the system. -
Sugar Integrate for DealHub
FEATUREDAre complicated price structures slowing down sales? Sugar Integrate for DealHub supercharges your sales team quoting capabilities and delivers high quality proposals to your customers directly within... - Show more addons