This 10-step tutorial will assist you in creating custom tokenized links. Such links, combined with the great Advanced Contact module, allow you to create links which automatically select a category on the contact page. You may even send tokenized subject information.

The end result may look, for instance, like this:
<a href="../contact&category=General&subject=Request for information regarding: [title]">Ask for information</a>

Assuming you have created a category called "General" for your contact forms, this links will open the contact page with "General" as the category and "Request for information regarding: Node-title-will-be-here" as the subject.

So, how does this work?

1. Download, enable and configure CCK.module

2. Download and enable Tokenize.module (which requires Token.module). Sep. 04 2008: Note tokenize issues #294940, #273294 and #283480.

3. Download and enable the Advanced Contact.module.

4. Go to admin > content > types and select the desired content type. Then click on the "Add field" tab.

5. Specify a name for the field. Then, select Text > Text Field as the field type and hit the "Create field" button. (The Text module in the CCK modules fieldgroup must be enabled for this field type to be used.)

6. Give your new field a label.

7. Now for the magic. Enter the desired link under "Default value", and set your tokenization method under "Tokenization" (more information regarding the two "on" options is available on the Tokenize.module project page). Set the rest of the options as desired, and click on "Save field settings".

A few examples of tokenized links:
<a href="../print/[nid]">Print page</a> - This will links to the Print.module version of the node (if available).
<a href="../contact&category=Products&subject=A question about: [title]">Print page</a> - Will send the user to the contact page, have the "Products" category selected and prefill the subject with "A question about: Title-Of-The-Node".

8. Because of issue #273294, you must again edit the field, and select the proper default input format. Note that if using the standard formats, you will need to use the "Full HTML" format for the links (as stated above) to function.

9. Set the Display option for the field as desired.

10. Create a new node - A prefilled CCK text field will be displayed. If you don't change anything in it, when submitting the form the field will display the proper links.

Simple, fun and highly effective.

Enjoy.

Comments

gscerb’s picture

I'm using Drupal 6, Token 6.x and Advanced Contact 6.x. I am able to link to the Contact form and fill in the correct category. However the [token] field doesn't work. I suspect since Tokenize is only 5.x and I haven't downloaded it.

Is there a way to use the [token] capability in Drupal 6?

UNarmed’s picture

Hey would this work for drupal 6 to?

UNarmed’s picture

Here is something i stubled upon that i am using for this functionality http://drupal.org/node/296453#webform-url-default and it works great with drupal6

xl_cheese’s picture

I really like the idea of being able to do this, but the token literally comes out printed as "[title]".