{"id":587,"date":"2014-09-25T09:04:19","date_gmt":"2014-09-25T16:04:19","guid":{"rendered":"http:\/\/www.keganv.com\/?p=587"},"modified":"2014-09-25T10:57:03","modified_gmt":"2014-09-25T17:57:03","slug":"how-to-modify-the-user-menu-in-orocrm","status":"publish","type":"post","link":"https:\/\/www.keganv.com\/how-to-modify-the-user-menu-in-orocrm\/","title":{"rendered":"How To Modify The User Menu In OroCrm"},"content":{"rendered":"<p><a href=\"https:\/\/www.keganv.com\/wp-content\/uploads\/usermenu.png\"><img decoding=\"async\" src=\"https:\/\/www.keganv.com\/wp-content\/uploads\/usermenu.png\" alt=\"Oro Custom User Menu\" class=\"aligncenter\" \/><\/a><br \/>\nModifying the drop down user menu within the OroCrm is quite easy&#8230; once you figure out exactly how it&#8217;s done. There isn&#8217;t really clear documentation on how to go about doing it, but after a couple hours of going off of what <a href=\"https:\/\/github.com\/orocrm\/platform\/blob\/master\/src\/Oro\/Bundle\/NavigationBundle\/README.md\" target=\"_blank\">the docs do give you<\/a> I was able to remove the links I needed to and add in the others that replaced them. I&#8217;ll also show you how to use a translation file to create your link labels.<br \/>\n<!--more--><\/p>\n<h3>Getting Started<\/h3>\n<p>First off I&#8217;m going to assume that you&#8217;ve already created a bundle that is either completely new or extending another bundle. For me I am working in a UI bundle in my namespace that extends the Oro platform UI bundle. In your bundle, which if you are following Oro&#8217;s directory structure convention should look like <code>src\/YourName\/Bundle\/YourBundle\/Resources\/config\/<\/code>, you need to create a navigation.yml file. Oro uses these files to structure and generate navigation menus and page titles. Page titles are defined under a node of <code>oro_titles<\/code>, but for this short lesson I&#8217;m not concerned with creating new pages that don&#8217;t already have page titles, so I&#8217;m leaving that out.<\/p>\n<p>If you dig down into your vendor folder under the oro platform directory, you&#8217;ll find that a bundle called UserBundle. This is a good place to start. Taking a look at its navigation.yml file, (under the config folder), you&#8217;ll see a list under the node <code>items:<\/code> which is under the global <code>oro_menu_config<\/code> node. Further down the file you&#8217;ll see a <code>tree:<\/code> node and under that is the <code>usermenu:<\/code> node. Bingo, that&#8217;s the guy we want to override. Have a look at a very shortened version of this file below, I condensed it for clarity and purposes of this tutorial.<\/p>\n<pre>\r\noro_menu_config:\r\n    items:\r\n        # other items ...\r\n        oro_user_profile_view:\r\n            label: 'oro.user.menu.oro_user_profile_view.label'\r\n            route: 'oro_user_profile_view'\r\n            extras:\r\n                position: 10\r\n    tree:\r\n        usermenu:\r\n            children:\r\n                oro_user_profile_view: ~\r\n\r\n<\/pre>\n<h3>Creating The New YAML Files<\/h3>\n<p>Here is the cool part, to override the existing links and add your own to the menu is as easy as creating your navigation.yml file under your config directory in your bundle I mentioned earlier. The project I&#8217;m working on required the links &#8220;My Profile&#8221;, &#8220;My Task List&#8221;, &#8220;Manage Users&#8221;, &#8220;Data Import &#038; Integrations&#8221;, and &#8220;Customization Settings&#8221;. This meant that I needed to remove the default links given out of the box from Oro. Have a look below at the new navigation.yml file which gets compiled after Oro&#8217;s core navigation.yml files, therefore overriding default structure.<\/p>\n<pre>\r\noro_menu_config:\r\n    items:\r\n        # REMOVE ORO DEFAULT LINKS\r\n        oro_user_profile_view:\r\n            display: false\r\n        task_list:\r\n            display: false\r\n        oro_calendar_view_default:\r\n            display: false\r\n        oro_email_user_emails:\r\n            display: false\r\n\r\n        # ADD OUR LINK ITEMS\r\n        ae_profile_view:\r\n            label: 'ae.user.menu.profile_label'\r\n            route: 'oro_user_profile_view'\r\n            extras:\r\n                position: 10\r\n        ae_task_list:\r\n            label: 'ae.user.menu.task_label'\r\n            route: 'orocrm_task_index'\r\n            extras:\r\n                routes: ['orocrm_task_*']\r\n                description: 'orocrm.task.menu.task_list.description'\r\n                position: 15\r\n        ae_user_list:\r\n            label: 'ae.user.menu.user_manage_label'\r\n            route: 'oro_user_index'\r\n            extras:\r\n                routes: ['\/^oro_user_(?!role\\w+|group\\w+|security\\w+|reset\\w+)\\w+$\/']\r\n                description: 'oro.user.menu.user_list.description'\r\n                position: 20\r\n        ae_import_integrations:\r\n            label: 'ae.user.menu.import_integrations_label'\r\n            uri: '#'\r\n            extras:\r\n                position: 25\r\n        ae_customization_settings:\r\n            label: 'ae.user.menu.customization_settings_label'\r\n            uri: '#'\r\n            extras:\r\n                position: 30\r\n\r\n    tree:\r\n        usermenu:\r\n            children:\r\n                oro_user_profile_view: ~\r\n                task_list: ~\r\n                oro_calendar_view_default: ~\r\n                ae_profile_view: ~\r\n                ae_task_list: ~\r\n                ae_user_list: ~\r\n                ae_import_integrations: ~\r\n                ae_customization_settings: ~\r\n\r\n<\/pre>\n<p>What I&#8217;ve done here is first removed the default links under the <code>items:<\/code> node with <code>display: false<\/code>. Then I created my new items that I want to display on the user menu. I simply hunted for Oro&#8217;s configuration for these items under other navigation.yml files and changed the item name and a new label translation, more on that in a moment. You&#8217;ll notice an &#8220;ae&#8221; at the beginning of my item names, this is simply just using my namespace for good practice. You can name them whatever you want semantically. Finally, under the <code>tree:<\/code> -> <code>usermenu:<\/code> -> <code>children:<\/code> I&#8217;ve declared those items which will refer to the items under the <code>oro_menu_config<\/code> node and their config values.<\/p>\n<h3>Creating The Translations<\/h3>\n<p>Creating the translations for the labels is easy peasy. Under your Resources directory, simply create a new folder called &#8220;translations&#8221; and create a &#8220;messages.en.yml&#8221; file (for English translations). Inside this file you simply declare your hierarchy of labels. In this case I put everything under a top node of <code>ae:<\/code>, my namespace. It&#8217;s pretty straightforward how the labels get translated. For example, the label <code>'ae.user.menu.task_label'<\/code> gets traversed with each dot indicating (typically) a child node. So, it looks at the nodes <code>ae:<\/code> then <code>user:<\/code> then <code>menu:<\/code> then the <code>task_label:<\/code> node which contains the actual translation. Side note: Isn&#8217;t YAML clean and great?!<\/p>\n<pre>\r\nae:\r\n    user:\r\n        menu:\r\n            profile_label: My Profile\r\n            task_label: My Task List\r\n            user_manage_label: Manage Users\r\n            import_integrations_label: Data Import & Integrations\r\n            customization_settings_label: Customization Settings\r\n<\/pre>\n<p>That&#8217;s it, you may have to clear your cache, but you should be seeing a new user menu full of your custom navigation now! If you know of another tip or better way of doing something, please leave your comments below!<\/p>\n","protected":false},"excerpt":{"rendered":"Modifying the drop down user menu within the OroCrm is quite easy&#8230; once you figure out exactly how it&#8217;s done. There isn&#8217;t really clear documentation on how to go about doing it, but after a couple hours of going off of what the docs do give you I was able to remove the links I &#8230; <br\/> <a class=\"view-article btn btn-primary flip pull-left\" href=\"https:\/\/www.keganv.com\/how-to-modify-the-user-menu-in-orocrm\/\"><span>View Article<\/span><\/a>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-587","post","type-post","status-publish","format-standard","hentry","category-coding-programming"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How To Modify The User Menu In OroCrm | KeganV<\/title>\n<meta name=\"description\" content=\"Learn how to easily modify the drop down user menu within the OroBap or OroCrm.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.keganv.com\/how-to-modify-the-user-menu-in-orocrm\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How To Modify The User Menu In OroCrm | KeganV\" \/>\n<meta property=\"og:description\" content=\"Learn how to easily modify the drop down user menu within the OroBap or OroCrm.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.keganv.com\/how-to-modify-the-user-menu-in-orocrm\/\" \/>\n<meta property=\"og:site_name\" content=\"KeganV\" \/>\n<meta property=\"article:published_time\" content=\"2014-09-25T16:04:19+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2014-09-25T17:57:03+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/www.keganv.com\/wp-content\/uploads\/usermenu.png\" \/>\n<meta name=\"author\" content=\"Kegan V.\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Kegan V.\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.keganv.com\/how-to-modify-the-user-menu-in-orocrm\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.keganv.com\/how-to-modify-the-user-menu-in-orocrm\/\"},\"author\":{\"name\":\"Kegan V.\",\"@id\":\"https:\/\/www.keganv.com\/#\/schema\/person\/412e7755f594475dc403b6d774b80276\"},\"headline\":\"How To Modify The User Menu In OroCrm\",\"datePublished\":\"2014-09-25T16:04:19+00:00\",\"dateModified\":\"2014-09-25T17:57:03+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.keganv.com\/how-to-modify-the-user-menu-in-orocrm\/\"},\"wordCount\":647,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\/\/www.keganv.com\/#\/schema\/person\/412e7755f594475dc403b6d774b80276\"},\"articleSection\":[\"Coding &amp; Programming\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.keganv.com\/how-to-modify-the-user-menu-in-orocrm\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.keganv.com\/how-to-modify-the-user-menu-in-orocrm\/\",\"url\":\"https:\/\/www.keganv.com\/how-to-modify-the-user-menu-in-orocrm\/\",\"name\":\"How To Modify The User Menu In OroCrm | KeganV\",\"isPartOf\":{\"@id\":\"https:\/\/www.keganv.com\/#website\"},\"datePublished\":\"2014-09-25T16:04:19+00:00\",\"dateModified\":\"2014-09-25T17:57:03+00:00\",\"description\":\"Learn how to easily modify the drop down user menu within the OroBap or OroCrm.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.keganv.com\/how-to-modify-the-user-menu-in-orocrm\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.keganv.com\/how-to-modify-the-user-menu-in-orocrm\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.keganv.com\/how-to-modify-the-user-menu-in-orocrm\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.keganv.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How To Modify The User Menu In OroCrm\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.keganv.com\/#website\",\"url\":\"https:\/\/www.keganv.com\/\",\"name\":\"KeganV\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/www.keganv.com\/#\/schema\/person\/412e7755f594475dc403b6d774b80276\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.keganv.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/www.keganv.com\/#\/schema\/person\/412e7755f594475dc403b6d774b80276\",\"name\":\"Kegan V.\",\"logo\":{\"@id\":\"https:\/\/www.keganv.com\/#\/schema\/person\/image\/\"},\"sameAs\":[\"http:\/\/www.keganv.com\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How To Modify The User Menu In OroCrm | KeganV","description":"Learn how to easily modify the drop down user menu within the OroBap or OroCrm.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.keganv.com\/how-to-modify-the-user-menu-in-orocrm\/","og_locale":"en_US","og_type":"article","og_title":"How To Modify The User Menu In OroCrm | KeganV","og_description":"Learn how to easily modify the drop down user menu within the OroBap or OroCrm.","og_url":"https:\/\/www.keganv.com\/how-to-modify-the-user-menu-in-orocrm\/","og_site_name":"KeganV","article_published_time":"2014-09-25T16:04:19+00:00","article_modified_time":"2014-09-25T17:57:03+00:00","og_image":[{"url":"http:\/\/www.keganv.com\/wp-content\/uploads\/usermenu.png"}],"author":"Kegan V.","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Kegan V.","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.keganv.com\/how-to-modify-the-user-menu-in-orocrm\/#article","isPartOf":{"@id":"https:\/\/www.keganv.com\/how-to-modify-the-user-menu-in-orocrm\/"},"author":{"name":"Kegan V.","@id":"https:\/\/www.keganv.com\/#\/schema\/person\/412e7755f594475dc403b6d774b80276"},"headline":"How To Modify The User Menu In OroCrm","datePublished":"2014-09-25T16:04:19+00:00","dateModified":"2014-09-25T17:57:03+00:00","mainEntityOfPage":{"@id":"https:\/\/www.keganv.com\/how-to-modify-the-user-menu-in-orocrm\/"},"wordCount":647,"commentCount":2,"publisher":{"@id":"https:\/\/www.keganv.com\/#\/schema\/person\/412e7755f594475dc403b6d774b80276"},"articleSection":["Coding &amp; Programming"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.keganv.com\/how-to-modify-the-user-menu-in-orocrm\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.keganv.com\/how-to-modify-the-user-menu-in-orocrm\/","url":"https:\/\/www.keganv.com\/how-to-modify-the-user-menu-in-orocrm\/","name":"How To Modify The User Menu In OroCrm | KeganV","isPartOf":{"@id":"https:\/\/www.keganv.com\/#website"},"datePublished":"2014-09-25T16:04:19+00:00","dateModified":"2014-09-25T17:57:03+00:00","description":"Learn how to easily modify the drop down user menu within the OroBap or OroCrm.","breadcrumb":{"@id":"https:\/\/www.keganv.com\/how-to-modify-the-user-menu-in-orocrm\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.keganv.com\/how-to-modify-the-user-menu-in-orocrm\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.keganv.com\/how-to-modify-the-user-menu-in-orocrm\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.keganv.com\/"},{"@type":"ListItem","position":2,"name":"How To Modify The User Menu In OroCrm"}]},{"@type":"WebSite","@id":"https:\/\/www.keganv.com\/#website","url":"https:\/\/www.keganv.com\/","name":"KeganV","description":"","publisher":{"@id":"https:\/\/www.keganv.com\/#\/schema\/person\/412e7755f594475dc403b6d774b80276"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.keganv.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/www.keganv.com\/#\/schema\/person\/412e7755f594475dc403b6d774b80276","name":"Kegan V.","logo":{"@id":"https:\/\/www.keganv.com\/#\/schema\/person\/image\/"},"sameAs":["http:\/\/www.keganv.com"]}]}},"_links":{"self":[{"href":"https:\/\/www.keganv.com\/api\/wp\/v2\/posts\/587"}],"collection":[{"href":"https:\/\/www.keganv.com\/api\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.keganv.com\/api\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.keganv.com\/api\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.keganv.com\/api\/wp\/v2\/comments?post=587"}],"version-history":[{"count":10,"href":"https:\/\/www.keganv.com\/api\/wp\/v2\/posts\/587\/revisions"}],"predecessor-version":[{"id":598,"href":"https:\/\/www.keganv.com\/api\/wp\/v2\/posts\/587\/revisions\/598"}],"wp:attachment":[{"href":"https:\/\/www.keganv.com\/api\/wp\/v2\/media?parent=587"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.keganv.com\/api\/wp\/v2\/categories?post=587"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.keganv.com\/api\/wp\/v2\/tags?post=587"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}