Menu Token is not working at all. First I tried dev (march 17) that broke all menu. Then I tried alpha1 version of March 22. It is showing token but I keep getting this message: The path 'members/[user-name]' is either invalid or you do not have access to it. As if menu token didnt change any functioning except showing the token. Has anybody tried this Alpha1 version?

CommentFileSizeAuthor
#4 menu_token-1117760-4.patch988 bytesdealancer
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sandino’s picture

Did you check Use tokens in title and in path checkbox on 'Edit menu item' page?

amaster’s picture

I have the same problem. It is not working. I get the message "The path 'members/[user-id]' is either invalid or you do not have access to it".
P.S. I checked the "Use tokens in title and in path" checkbox.

Squiggles’s picture

I also have the same problem, even with the "Use tokens in title and in path" enabled.

whenever I use [user-id], it disappears, and replaces my input to < front >.

dealancer’s picture

Status: Active » Fixed
FileSize
988 bytes

I confirm, the issue is still exists there. It have been fixed in the dev, however in the dev there are other bugs. So you could use this path to fix it.

dealancer’s picture

Version: 6.x-1.0-alpha1 » 7.x-1.0-alpha1
Assigned: Unassigned » dealancer
Status: Fixed » Active

It have been fixed in D7 version of this module, but we need it to fix for D6 version.

dealancer’s picture

Version: 7.x-1.0-alpha1 » 6.x-1.0-alpha1
Assigned: dealancer » DevElCuy
Status: Active » Fixed

Fixed in dev version.

Another reason we need this fix is for:

a) support of user/node/taxonomy/custom tokens, otherwise path won't be validated
b) menu added by user who have no access to some pages
c) anyway access to menu item is checked when it is showed

dealancer’s picture

Assigned: DevElCuy » dealancer
Squiggles’s picture

Sorry, it still doesn't work for me, both for this patched version and the dev version.

I'm currently building a menu for the control panel of my site. whenever I use user/[user-id]/community, it doesn't process [user-id] correctly. I still end up with a blank entry.

Derjyn’s picture

Yeah, this isn't working at all. Using the forked version referenced at http://drupal.org/node/973882#comment-4199454 got me to at least be able to see the menu token field when adding menu items, but no proper link is created, and the item isn't even added to the menu, even though it is a listed link on the menu edit interface.

Looks like this has a lot of work needed! Out of curiosity, has this ever worked?

dealancer’s picture

Status: Fixed » Needs review

Have you tried to run update.php when updating to 6.x-1.x-dev?

Squiggles’s picture

yes, that was done quite a number of times. still, it didn't work.

dealancer’s picture

Squiggles, could you give us your list of modules that are enabled on this website. Is it working for you for fresh Drupal installation?

Squiggles’s picture

Hi dealancer,

I'm currently using this under a fresh install with default modules set, without CCK and Views enabled yet. Drupal version is 6.2. I've tried using this with 'me' alias both enabled and disabled. So far, even under a fresh installation, it doesn't work for me.

Dublin Drupaller’s picture

menu token doesn't work as expected for me...plus, I'm having trouble uninstaling it.

jrz’s picture

Tried using [user-name] for anew menu item and it doesnt work.

jrz’s picture

Back again. in my case, I ended up creating a static menu to a view and used the view to filter some of the content out.

timmetj’s picture

please fix tokens in menu title! I can't use [user-name] in the menu title... I'm using latest version 6.x-1.0-alpha2

If I remove the IF statement in menu_token.module line 17-21 and the close bracket on line 48, I can see the user name in the backend admin menu page, but not on the primary/secondary menu on the frontend

dealancer’s picture

Hey guys,

Do you use any menu related modules? If yes there is a separate issue for that, see link on front page.

miccelito’s picture

I think that the problem might be that if you are using module Pathauto and have set url aliases, you must enter the original url and not the url alias in the menu link field when using MenuToken.

peter292’s picture

Version: 6.x-1.0-alpha1 » 6.x-1.0-alpha2

Every time I checked off the box to use tokens in path, the menu item disappeared. If I unchecked it, the menu item came back. After exhausting every combination I could think of, including trying out the util module to experiment with putting different "weights" on the various modules involved with menu, I finally bailed out and found a different module to do the job, called "me", which uses the
token called "me" to provide the current user id.

Yuri’s picture

I confirm that this module for Drupal 6 - the alpha 2 version- does not work well. I encountered inconsistent behavior of tokened menu items being visible and not being visible. I used the original urls. In my case it appears in the marketplace module seller links on a clean install.

dealancer’s picture

Status: Needs review » Postponed (maintainer needs more info)

Could you guys, describe, please, what are you doing to module is not working?

dealancer’s picture

Priority: Critical » Normal
reallyordinary’s picture

Doesn't seem to work at all for linking to content with pathauto generated URL aliases.

Which is a shame, because... I'm trying to add a user menu item and the only way to generate a custom link to it properly tailored for each users is via the pathauto alias, because the original URL is just node/nid, and I can't grab the underlying nid.

So... any chance there'll ever be some kind of patch to make this compatible with pathauto?

fehin’s picture

This isn't working for me either. I have been trying to use it for the profile paths and ubercart marketplace links.

miccelito’s picture

I've also noticed that Menu token is only able to give such tokens for currently logged-in user and not for other users. So you've better create a menu block using Views and set an argument UID (Provide default argument > User ID from URL).

frixos12’s picture

subscribing

Yuri’s picture

Priority: Normal » Major

As a workaround i found this solution: http://yuriybabenko.com/blog/using-user-id-arguments-in-drupal-menu-items

However, in order to keep this issue out of an impasse: Can someone please confirm that the installation of this menu module actually works with the user ID of the currently logged in user? Until someone confirms, this apparently does not work.
Maintainers, please reply. Thanks.

wickedskaman’s picture

Subscribing. Same issue as above. Not working at all. Pathauto is on but none of the token are working not even with a valid path and using a token in the Link Title field. Just shows up as "[site-name]" or whatever token I use.

miccelito’s picture

Mentioned before as for information ...

The MenuToken tokens currently not work for the Menu link title field but only for the Path field.
All of the MenuToken tokens work (as long they're used in the Path field).
You cannot use/type alias path but only origin (system) path together with MenuToken tokens - the link will howsoever automaticly link correctly to alias url if such exists for the current origin (system) path.
As for now only available user related tokens is for currently logged-in user - even thought it would be great if MenuToken also could have user related tokens based on user id from URL.

wickedskaman’s picture

I have not found that to be the case. Here's a use case that did not work for me that should have:
Link title: "My account"
path: user/[uid]
Result: path is /

Another:
Link title: "My account"
path: user/[user-name]
Result: path is /

Both of these are valid paths using valid tokens for a logged in user. They did not work. Thoughts?

miccelito’s picture

I guess you mean

Link title: "My account"
Path: user/[user-id]

I have tried as well
path: user/[user-name]
and it seems to work.

klokie’s picture

I also want to use the path node/[user-id]/work-items but that just gets reset to path <front> every time I save.
I've tried versions 6.x-1.0-alpha2 and 6.x-1.0-dev (which is older than the alpha2 branch anyway).

miccelito’s picture

@klokie: Are you really sure that the path is 'node/[user-id]/work-items' ? Doesn't sound like a correct path..

wickedskaman’s picture

Have tried those and various valid paths. All reset to <front> *shrug*

klokie’s picture

@klokie: Are you really sure that the path is 'node/[user-id]/work-items' ? Doesn't sound like a correct path..

Yes, I am certain. I have tried several different paths which were all valid for the logged-in user. All were reset to <front>.

Alex Savin’s picture

I can confirm the bug. Just installed it and nothing works. Basically, I get empty query menu items. Somewhere the path is overwritten with a blank one. The menu item edit form though looks ok. The path (with tokens) appears correct but when rendered it has a empty query.

gMaximus’s picture

Hi...

I too have been experiencing issues getting this to work on my site. Specifically some ubercart marketplace links....

One of the menu links i was trying to get to work was: user/[user-id]/selling/settings ... This link would show if a user went to their user page but would not display otherwise. It would also display fine for administrators....

Anyway, I just stumbled across this little gem that fixed all my issues.... I replaced the path to: [site-url]user/[user-id]/selling/settings

Hey presto, my problems were solved....

Hope this helps others.....

Guy

hbat66’s picture

guyd's recommendation worked for my site. Adding the [site_url] token before the path token I am directing my link to worked. Strange, but awesome.

dealancer, could you write a patch that negates having to add the [site_url] token? Either way, thanks for the module.

citkane’s picture

Can confirm that #38 worked for me. Thanks - was about to throw a computer through a window and move to the North Pole! Sanity has now returned.

PS - I am using 7 and the problem is there as well. Just changed the tokens to 7 version as per logic of #38

DevElCuy’s picture

Version: 6.x-1.0-alpha2 » 7.x-1.x-dev

D6 is discontinued. We appreciate all your feedback, we are prioritizing D7 and start working on D8. Please contact maintainers directly if you need support.

rickharington’s picture

Hi guys, maybe some extra info. I'm on menu_token-7.x-1.0-beta4.tar.

I created a menu item with tokens and ticked the box Use tokens in title and in path and nothing showed up. I was using tokens in both title and path. Then I ticked the user form context and got the errors above, the whole time and every time I tried to change something I got the same error. The path '[I cant remember]' is either invalid or you do not have access to it.

I then deleted the menu item, then ticked Use tokens in title and in path first, then user form context and then added [current-user:name] and [site:url]user/[current-user:uid] as my title and token. Worked perfectly.

I don't know if it's just the right combination or the workflow but I hope it helps someone.

R

dan2k3k4’s picture

My tokens for the title (trying to set username to a menu title) show up as the tokens... e.g. [user:name] shows as [user:name] and not 'admin' (if current logged in user is admin).

Will try test on a fresh Drupal install later on.

astutonet’s picture

Priority: Major » Critical
Status: Postponed (maintainer needs more info) » Needs work

Hi

I think this issue is related: #1915376: Invalid argument supplied for foreach() in menu_token_module when using Crumbs and i18n modules.

Initially, when I installing the module, I received the following error messages:

Warning: Invalid argument supplied for foreach() in menu_token_translated_menu_link_alter() (line 104 of C:\wamp\www\mysite\sites\all\modules\menu_token\menu_token.module).
Warning: Invalid argument supplied for foreach() in menu_token_translated_menu_link_alter() (line 104 of C:\wamp\www\mysite\sites\all\modules\menu_token\menu_token.module).

Even so I tried to use it. So, when I inserted the tokens in the urls, the menu items simply disappeared.

So, I needed to disable the module and to open the issue above, because I did not believe that these issues were related. Today, reanalyzing the issues, I believe they are related.

It happens that this is the only module capable of generating dynamic links, therefore, is a module of extreme importance to the community and deserves more attention.

For this reason I enabled the module again, and I realize now that it is generating the urls correctly, but the same above error message is still displayed on all pages of the site.

(Edited: After clicking in the link of menu with Token, the linked page opens, but the link disappears of the menu and not return to be displayed again)

In the block of line 104 of the menu_token.module file, we have the following code:

    // Load data objects used when replacing link.
    if (isset($item['options']['menu_token_data'])) {
      foreach ($item['options']['menu_token_data'] as $type => $values) {
        if (!empty($info['types'][$type]) && $handler = menu_token_get_handler($values['plugin'])) {
          $values['options']['_type'] = $type;
          if ($object = $handler->object_load($values['options'])) {
            $data[$type] = $object;
          }
        }
      }
    }

Anyone have any idea?

Tks.

Note 1: This issue occurs in 7.x-1.0-beta4 and 7.x-1.x-dev versions.
Note 2: When a module does not reach your goal, it ceases to be functional, which is why I see this issue as critical.

astutonet’s picture

Component: Miscellaneous » Code
Assigned: dealancer » Unassigned
Category: task » bug

The issue of the disappearance of menu items is related to: #1203184: Menu created with menu token not appearing

Enter the absolute path, as recorded in the question above (#30) solves the problem.

It remains to solve the problem with the error message at line 104 of the menu_token.module file, because the error message is displayed on all pages of the site.

Any idea?

a.ross’s picture

Priority: Critical » Normal
Status: Needs work » Postponed (maintainer needs more info)

This could very well be specific to your configuration, so more testing is needed. Also, this issue is a bit general, so let's continue this in #1915376: Invalid argument supplied for foreach() in menu_token_module when using Crumbs and i18n modules

pinkonomy’s picture

I still have this issue . The token for the user doesn't work .I also tried the #38 but still I get wron results: Dummy Menu Token item
How can this be fixed? My path is user/[current-user:uid]/edit
thanks

deanflory’s picture

Maybe using the me module would allow you to put in a path like user/me/edit

I too think I had issues with getting a link to editing Profile2 or core account links, can't remember the details now.

lameei’s picture

I'm trying to do the same mention in #48. I've tried the solution in #38 the generated links is correct but leads to WSOD. even when i want to edit the menu i get WSOD.

flatfeat’s picture

Issue summary: View changes

Finally got this working after a bit of playing around. I wanted a link with the path /user/[userid]/orders.

Got that finally after installing the most recent development version of the module, plus installed the required UUID module. I also enabled the included UUID path module.

For the menu link path I put:

user/[current-user:uid]/orders

And it's now working. Note that in the admin screen for the menu, it displays a path for this link as something like menutoken/840394938f. But the actual link on the front end of the site is working.

flatfeat’s picture

Never mind, spoke too soon. Putting user/[current-user:uid]/orders works great when logged in as user/1, but the link disappears when logged in as another user. Which is the whole point to begin with...

Putting user/[user:uid]/orders doesn't work at all.

Oh Drupal. You're like an abusive girlfriend who treats me badly half the time, but I cannot leave you. :-D

My solution will be to abandon this module and simply create a block with the php filter enabled.

thirdender’s picture

I was trying to create a link to user/[current-user:uid]/addressbook/shipping when I got the "invalid or you do not have access " error. After clearing all caches I was able to create the menu item fine. One thing I noticed was that before clearing the caches the "Menu Token options" fieldset seemed to be missing. Module is working great now :-)

chrbak’s picture

I think that the basic problem is that when updating an existing menu item with tokens the link ( menutoken/{random_string} which is correct) breaks by giving to the token (e.g. [current-user:uid]) a fixed value (e.g. 1, if you are logged in as user/1).

So the solution is NOT to update an existing menu item with tokens or change the weight of the specific menu item (you can change the weigths of other menu items that have no tokens) at manage form menu and 'Save configurations'. If you do that you must delete the menu item and create it again or follow the #8 instructions.

BDaggerhart’s picture

I'm getting this same issue. When I initially create a menu item w/ menu tokens, for instance, to create a link to a view for a user (example: mysite.com/user/[user:uid]/view-name ), I put the path, and then check "Use tokens in title and in path," and then select "User from context" under Method for Users (for that last step, I've tried many different variations, everything still ends up the same). When I create the menu item, it saves, but the menu item never actually shows up. Then if I edit the menu, I get the error:

"The path 'user/[user:uid]/view-name' is either invalid or you do not have access to it."

EDIT: My particular case has been fixed by using [current-user:uid] instead of [user:uid]

DevElCuy’s picture

@BDaggerhart, have you tried with [current-user:uid] instead of [user:uid] ?

BDaggerhart’s picture

@develCuy
Well I'll be darned, I don't know how I missed that, but that ended up working fine. Thanks!

cthshabel’s picture

#58 is exactly correct. I experience the same. thanks chrbak

cthshabel’s picture

I was able to get this working by adding the absolute path to the beginning even after doing an update on the link. So I did this:

[site:url]user/[current-user:uid]

and it worked.

Not sure why this happens, but it's a workaround.

matt.rad’s picture

#53 worked for me.

cscott5288’s picture

This module is fucked. Not only do you get error messages when using tokens, but you can't delete the menu item that has errors on it ... it just gets stuck loading the menu item.

DevElCuy’s picture

@cscott5288, you are right :) That is why Menu Token stays in beta stage. If you are not ready to deal with beta stuff, don't use it.

cthshabel’s picture

#53 does explain the issue.

#42 was what worked for me as I mention in #58

unfortunatley, @cscott5288 is correct that the menu links using tokens can't be deleted either. Seems like a problem.

cthshabel’s picture

Just wanted to leave a note for others here, Sub path auto module has an issue in it's queue here. This issue was breaking menu token for us. It was causing the menu link tokens to enter a loop when trying to edit or delete. Worth noting is comment #15 in that issue. If you have custom or contrib modules that use menu_get_item like Volx mentions, this could cause major problems with menu token.

Anyways, we are back on track with menu token, colorbox node, and sub path auto all playing nice together! For now :)

Nixou’s picture

Hi,

I found a way to have menu link with token editable without error message and without recreate the menu link.
I hope this may help others, waiting a fix in the module.

You need to have a custom module call after menu_token (for example "menu_token_override") and add this piece of code in your .module file :

<?php

/**
 * Implements hook_form_FORM_ID_alter().
 */
function menu_token_override_form_menu_edit_item_alter(&$form, &$form_state, $form_id) {
  // Fix how menu token set the default link uuid.
  if (!empty($form['menu_token_uuid']) && !empty($form['mlid']['#value'])) {
    $result = db_select('menu_links', 'm')
      ->condition('mlid', $form['mlid']['#value'], '=')
      ->condition('router_path', 'menutoken/%', '=')      
      ->fields('m', array('link_path'))
      ->execute()
      ->fetchCol();
    
    if (!empty($result[0])) {
      $form['menu_token_uuid']['#value'] = $result[0];
    }
  }
}

This correctly defined the UUID menu link and prevents the error message.

Shiraz Dindar’s picture

#64 works for me. Thanks!

DevElCuy’s picture

@Nixou, thanks for that fix. I'm working on a patch based on your code.

divyesh19’s picture

#42 worked for me.

DevElCuy’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

We got another issue that might be related to this one: #2789023: [RC blocker] Problems overriding menu item path.

Also, this issue is 5 years old (with a pretty generic title...). We got several new releases, we fixed bugs as a community and got fun, so now is time to rip this issue and start the RC stage!

P.S: Yes! I'm closing this issues straight, please start a new issue if you find something not working. Thanks!

-Mania-’s picture

I know this is an old closed issue but it's likely to come up on Google etc. for people looking for answers so I'm placing my solution here. The only way I got this module to work was to use menu_token 7.x-1.0-beta5. This is the last version without UUID dependency so I think that might be related.

Now important settings for your menu item:

  • Enable option Use tokens in title and in path
  • Do NOT choose any method for Nodes/Users. Leave these disabled. Having an option here I got a site error and was unable to edit the links anymore
  • Enable option Remove token if replacement is not present
  • On first save the links may not work. Edit and save again and the token(s) should work

That was my success anyway. Hope it helps you. It's too bad this broken old module is the only viable solution to creating links like these for the navigation menu.

philsward’s picture

@-Mania-

You're a life saver!