« Rules links I don't want to lose | Main | Rip a chapter and convert the VOB file to flash »

October 22, 2010

Approximate a dynamically constructed link or menu item using Rules

Goal: Dynamically construct a link that forwards a user to their edit content profile page (e.g. www.foo.com/user/1/profile/person).

Problem: Drupal's Core menu system is not token-enabled. The tricky part is that the 1 must be dynamically replaced with the [User:ID] of whomever is logged in.

This concept can be applied to both internal links and menu items.
This is something of a workaround and there are no doubt other ways to accomplish this.

Some familiarity with all modules employed here.
A content type call Person which is part of the user profile.
No knowledge of PHP or the Drupal API.

Content Profile
Token - to get the User ID info
Path Rules - Allows you to "Check Path" of destination URL.

1) Create a Page. Call it pageX

2) Under "URL path settings" set a custom URL for pageX. Call it pageX-url. You can also just remember the Node ID and use that instead of a custom URL.

3) Pick a menu to modify (admin/build/menu) and add a menu item that directs users to pageX (path: pageX-url) when clicked on.

4) Configure a rule (admin/rules/trigger) that redirects users who are about to visit www.foo.com/pageX-url to www.foo.com/user/[user:ID]/profile/person:

- Event: "Content is going to be viewed"
- Condition: "Check Path" where the path to check for is "pageX-url"
- Action: "Page redirect" where To: user/[user:uid]/profile/person

5) Navigate to www.foo.com/pageX-url, you should be forwarded to the edit form of the user profile listed above.

Posted by kkwaiser at October 22, 2010 12:09 PM


Login to leave a comment. Create a new account.