New token support

superduperdan - May 1, 2009 - 14:42
Project:me aliases
Version:6.x-2.6
Component:Documentation
Category:support request
Priority:normal
Assigned:Unassigned
Status:active
Description

Hello, I am attempting to use the new Token feature to replace 'me' pattern with [user-name]. Not having any luck.

My steps so far:
1. /admin/settings/me Added the Token [user-name] in the first field.
2. add new menu item with the following path. user/[user-name]

Getting error message:

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

Please advise.

#1

cdale - May 1, 2009 - 22:05

Hmmm.. I hadn't really considered that usage. I'm not sure that would be that easy to achieve. I'll have a look at it though. You never know.

#2

cdale - May 1, 2009 - 22:15

You should be able to do this with pathauto though now that I think about it. If you go to site-building -> URL alaises -> AUtomated alias settings. Expand the user path settings option, and put user/[user-raw] or something similar in there, it should work just fine.

#3

superduperdan - May 3, 2009 - 23:48

Still not working for me. Are the steps I originally posted correct? I added the path as you mentioned but not sure how that works with the module settings. I'm confused how this new Token feature works. I can't seem to get a menu item installed with the path user/[user-name]. I appreciate your help on this. =)

#4

cdale - May 4, 2009 - 09:03

I'm not sure what you want is possible without custom coding. It might be a feature I can add in me, but I won't have the to look into this for at least another week.

#5

superduperdan - May 4, 2009 - 15:36

Here is what I don't get. Since the new update you now have the option of replacing 'me' with a token pattern in the module setup page(admin/settings/me). So I replaced 'me' with [user-name]. Now when I try to add a menu item with the path user/[user-name] the following message occurs.

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

My setup:
- Content Profile
- Panels to display user profiles

Here is an example of a profile on my site. http://tdotdating.unifieddata.ca/user/superduperdan
As you can see from the url the path user/[user-name] should be valid.

#6

cdale - May 4, 2009 - 21:24

This is because the token for the token for the me alias is not a menu path, it is something that the me module understands, not the drupal menu system. So if you're logged in as 'user1', then as that user, you can go to user/user1, and me will take care of letting the system know who user1 is. Me does not currently create a path for user/[user-name]. You could use something like user/%, but that will not be replaced with the user name, it will simply show there uid.

#7

peach - June 6, 2009 - 20:43

I simply fixed this issue by using absolute paths. e.g. http://www.example.com/user/me will work fine :)

#8

cdale - July 1, 2009 - 23:56
Status:active» fixed

I've just been digging into this, and I believe me already supports what is required to get this working.

You create the me alias as "[user-name]" as you already have, but instead of creating the menu path "user/[user-name]" you create it as "user/%".

In my testing this has worked for me. I'd love your feedback if you are still trying to achieve this.

#9

System Message - July 16, 2009 - 00:00
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

#10

liquidcms - October 16, 2009 - 06:51
Status:closed» active

sorry to re-open.. but i am not sure i get if this solves the "me token" issue.

i think i am trying to do what the poster is doing; which is to create dynamic menu items using me as a token for current logged in uid. is that correct?

so i currently have a hard coded links block with links like:

- user/1
- user/1/library
- user/1/bookmarks

etc...

and i would love to be able to use Drupal's menu system for this but would need to have a token for [uid].

using user/% oddly enough seemed to work and take me to user/me.. which almost is the right my account page except all my view blocks which i add there are missing since they rely of arg(1) as uid and they don't understand "me".. but.. more importantly, nothing like user/%/library works (gives same "The path 'user/%/library' is either invalid or you do not have access to it" error as dan reported).

#11

liquidcms - October 16, 2009 - 07:28

ok, i guess i didn't try enough of the links.

adding user/%/messages does work (messages is added by contact module).. so i suspect user/% style links added by other modules do work; but the ones i have created with Views (/library and /bookmarks in my example above) do not work

looking at code menu code from the menu router table there is no value for to_arg_functions, which ends up being the path validate downfall as it needs to be able to replace the % with something - perhaps this is a setting of some sort in Views (or a bug)

#12

liquidcms - October 16, 2009 - 07:36

wow, and simply adding a:1:{i:1;s:9:"me_to_arg";} into the menu_router table under entry for to_arg_functions and i am now able to add user/%/library as a menu item.... so at the moment.. i am going with a a Views bug as the cause of this??

#13

cdale - October 16, 2009 - 09:01

in regards to #10 and the reliance on arg(1), I'm currently working on a solution that would still allow me to work with these arguments, I just need a few days to finish it off, which I probably won't get for a couple of weeks. What you can actually use in the meantime, is menu_get_object(). Something like:

<?php
if (($user = menu_get_object('user')) && $user->uid == 1) {
 
// show something to user 1.
}
?>

I've actually added code explicitly in me to allow for this. Making it work for arg() is a whole other story that has caused me to clash with other modules, hence me trying to come up with an alternative solution.

In regards to the links created by views, views uses its own to_arg() function if I remember rightly, but I'm not sure why they are not working for you. I'd imagine it has something to do with arguments and the type of menu item you created through views.

#14

liquidcms - October 16, 2009 - 21:13

thans for the replies.. i think this particular issue is a views bug - but we'll see what they say about it

 
 

Drupal is a registered trademark of Dries Buytaert.