Menu Tokens Module for Drupal Site

<p>On the project I'm working lately there is need for many not so simple solutions - one of them involves using Profile2 module, for creating a multi level user profile page - like there is one page for e-mail and password, then there is second profile page for personal information and more.</p><p>To handle this tasks, I'm using Profile2 module, what works 90% great - the rest 10% that doesn't works includes - it doesn't integrates well with Panels module - speaking of Panels -<a href="http://www.reinisfischer.com/drupal-panels-when-best-used"&gt; I literally avoid them as far as I can</a>. Unfortunately I'm using Panels in this project - not much, but still.</p><p>I already faced a problem of displaying dynamic content in views- then I found an awesome solution - <a href="http://www.reinisfischer.com/drupal-create-dynamical-menus-menu-views">… Views</a>.</p><p>Today I found another great module - Menu Tokens.</p><h2>So back to the subject</h2><p>So there is need to provide a menu for logged in users, with links to their profile pages.</p><p>Default Drupal menu - doesn't offer use of token, I mean you can use - <em>user, user/logout</em>.. if you will try to use user/edit - things will break up... so we need to insert a custom token in that menu - for example <em>user/[uid]/edit</em> (what actually is default path for user profiles)</p><p>But again - default Drupal menu - doesn't allow (offer) to use tokens - and there is need for another implementation.</p><h2>I found a working solution - Menu Token</h2><p>Menu Token module provides tokens, that could be used in title or in path of menu items (links). For example, if you create a menu item with path: "user/[current-user:uid]", the url will be changed "on fly" to: "user/1" (assuming you are user 1).</p><p>Tokens are provided by&nbsp;<a href="https://www.drupal.org/project/token&quot; rel="nofollow">Token</a>&nbsp;module. Menu Token allows to use both global tokens and entity ones: node, user, term, etc. Entity tokens have several methods of substitution: from context, random and user defined.</p><h3>Menu token Resources</h3><p>Menu token functionality can be extended gracefully. Following some examples:</p><ul><li>Menu token module implements&nbsp;<a href="https://www.drupal.org/project/ctools&quot; rel="nofollow">Ctools</a>&nbsp;plugin system and allows to plug in new token handlers.</li><li>Use&nbsp;<a href="https://www.drupal.org/project/path_alias_xt&quot; rel="nofollow">Extended path aliases</a>&nbsp;to automatically translate paths like 'user/1/mycontent' to 'users/admin/mycontent'. Just need to create a 'root' path alias: 'users/admin'. See<span class="project-issue-issue-link project-issue-status-info project-issue-status-7"><a title="Status: Closed (fixed)" href="https://www.drupal.org/node/1320842">#1320842: Work with the Path Auto module</a></span>.</li><li><a href="https://www.drupal.org/project/superfish&quot; rel="nofollow">Superfish</a>&nbsp;integrates jQuery Superfish plugin with your Drupal menus. Use Superfish 1.9-beta5 or greater.</li><li><a href="https://www.drupal.org/project/menu_item_visibility&quot; rel="nofollow">Menu item visibility</a>&nbsp;exposes configurable and extendable visibility settings for menu links. You'll need to set module weights so that Devel node access &gt; Menu item visibility &gt; Menu token.</li></ul><h3>Known issues</h3><ul><li>There are modules that use same hook as Menu Token, they need to be executed in proper order. For example:&nbsp;<a href="https://www.drupal.org/project/menu_per_role&quot; rel="nofollow">Menu per Role</a>&nbsp;works well with a weight of 5.</li><li>Some weird behavior happens when not using absolute paths, please help us solve it once and for all!&nbsp;<span class="project-issue-issue-link project-issue-status-info project-issue-status-1"><a title="Status: Active" href="https://www.drupal.org/node/2099623">#2099623: When do you use [site-url] token?</a></span></li></ul><p>How I did setup a Menu tokens for me?</p><p><strong>Menu link title</strong></p><p><em>Messages</em></p><p><strong>Path</strong></p><p><em>user/[current-user:uid]/messages</em></p><p><span><span><img src="http://www.reinisfischer.com/sites/default/files/menutokens.jpg&quot; alt="Menu tokens" title="Menu tokens" width="1200" height="518"></span></span></p><p><em>Menu tokens</em></p><p>As you can see from screen above, after enabling menu tokens module you can use tokens in menu's.</p><p>Depending on complexity of your Drupal site - menu token can be a real time saver.</p><p>Though I haven't explored full potential of Menu Tokens module - I can admit - I'm glad it exists, and in one project I will use it for sure.</p>

Add new comment