6

Sounds simple enough, right? I can't find it anywhere. My contact form's path remains:

/contact/contact_us

And I have no idea where to change this. I have checked under the form settings at:

/admin/structure/contact/manage/contact_us

Which leads me to believe that perhaps all contact forms are in the structure:

/contact/[FORM_SYSTEM_NAME]

Is that the case or is it possible to change it?

UPDATE

What I really want is a simple ALIAS field per contact form, so I can set the url alias myself?

9

I went under Configuration --> URL Aliases, and added a new alias for /contact-us that points to /contact/contact_us

I expected the result to be that anyone typing in /contact-us would end up at /contact/contact_us, but instead the opposite is happening. Anyone typing in /contact/contact_us is now redirected to /contact-us and the page is shown there.

This is a little different from how Drupal 7 works, but this is the answer I needed.

  • Actually the path is Configuration->Search And Metadata->Url aliases – amol Jul 25 '16 at 13:01
2

You can, in fact, change it. To do that you should use a route subscriber service class.

Such class will implement the alterRoutes method which will give you the ability to change the path of the contact page.

I'll update with code examples when I'll be near my computer.

  • Actually, you can't change the route for just one contact form since they all use the same route. What you can do is register a new route that will display a contact form, sure. But I don't think that's the point, you don't want to do that for every contact form you're adding. You also don't register a custom route for every node you create. You just create aliases. – Berdir Mar 30 '16 at 20:25
  • I thought that the OP wanted to change to routes for all contact forms. Are you sure that the OP wants to change the route of only a single form? – Eyal Mar 30 '16 at 20:30
  • What I want is a URL Alias field per contact form. – coderama Mar 31 '16 at 15:45
1

Yes, that is the case. You can't change that.

That said, you can always add aliases and use whatever path you want as an alias for /contact/form-id. It's not available directly in the contact form (there's an issue open for that, though) but you have to manually add it from the alias overview page at admin/config/search/path.

  • Wait, you can't alias it with something like Pathauto? – Kevin Mar 31 '16 at 16:30
  • Pathauto currently supports content entities. So you can create aliases, but only manually and only from the global alias management page. As I said, there's an issue in the core issue queue to add an alias field to the contact form, would be relatively easy to implement but hasn't happened yet. – Berdir Mar 31 '16 at 16:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.