I've setup a contact directory and use the e-mail field to automatically generate e-mail forms for each person. I use pathauto to generate friendly URLs for each person's profile page (e.g. /contact/johndoe.html). When a user clicks on the link to the e-mail form, it brings up the form with a URL like /email/1130/field_email (where 1130 is the node ID for johndoe.html).

Is there a way to make the e-mail form URL friendly? Since these forms aren't content types, I don't see an option in pathauto to automatically generate these.

Rob

Comments

rgraves’s picture

Anybody been able to look into this?

bartezz’s picture

Version: 5.x-1.x-dev » 6.x-1.2

No news yet... been 2 years :)

Cheers

jaskegreen’s picture

Any word on this for v7?

Cheers

bartezz’s picture

Haven't tried yet but maybe this helps;
http://drupal.org/project/path_alias_xt

Cheers

PS. since I only have a handful of forms I managed by creating manual path aliases

tnanek’s picture

I've run into this issue on Drupal 7, and thus am providing my solution here.

I use the rules module to help fill in gaps that I feel are left by maintainers through the user interface.

Anyhow, here are two rules. You should alter it as needed prior to importing/saving it, since this is dependant on the specific url's in use. I am using pathauto to have my content at /people/[node-title] and thus wanted this to be at /people/[node:title]/email, and my field name is field_person_email, and content type is person.

These rules a) (after saving) insert a url alias when a node of type person is saved with an entry in the field and no path to overwrite and b) (prior to saving) delete the url alias, should one exist, when a node of type person has its title changed, or the field is left empty.

I've only tested the first of them. At the moment I don't have the time to test the latter. I should this evening and hopefully will remember to edit this post once I do.

And I'm using Rules-7.x-2.0 for these.

{ "rules_person_email_alias_creation" : {
    "LABEL" : "Person email alias creation",
    "PLUGIN" : "reaction rule",
    "TAGS" : [ "path" ],
    "REQUIRES" : [ "rules", "path" ],
    "ON" : [ "node_insert", "node_update" ],
    "IF" : [
      { "node_is_of_type" : { "node" : [ "node" ], "type" : { "value" : { "person" : "person" } } } },
      { "entity_has_field" : { "entity" : [ "node" ], "field" : "field_person_email" } },
      { "NOT path_alias_exists" : { "alias" : "\/people\/[node:title]\/email" } }
    ],
    "DO" : [
      { "path_alias" : {
          "source" : "email\/node\/[node:nid]\/field_person_email",
          "alias" : "people\/[node:title]\/email"
        }
      }
    ]
  }
}
{ "rules_person_email_alias_deletion" : {
    "LABEL" : "Person email alias removal",
    "PLUGIN" : "reaction rule",
    "WEIGHT" : "-5",
    "TAGS" : [ "path" ],
    "REQUIRES" : [ "rules", "path" ],
    "ON" : [ "node_presave" ],
    "IF" : [
      { "NOT entity_is_new" : { "entity" : [ "node" ] } },
      { "path_alias_exists" : { "alias" : "\/people\/[node-unchanged:title]\/email" } },
      { "OR" : [
          { "NOT data_is" : { "data" : [ "node-unchanged:url" ], "value" : "people\/[node:title]" } },
          { "entity_has_field" : { "entity" : [ "node" ], "field" : "field_person_email" } }
        ]
      }
    ],
    "DO" : [
      { "path_alias" : { "alias" : "\/people\/[node-unchanged:title]\/email" } }
    ]
  }
}