TomPich Posted October 15, 2023 Share Posted October 15, 2023 (edited) Hello again, So now that I have the basics of PW in minds, here is the most important question to be 100% comfortable : How can I get and process data sent with POST in a specific file, dedicated to this logic? Let’s take the example of a contact form (I know there is a module for that, but I want to be able to handle post data in other contexts). When I develop from scratch, the strategy would be to define a specific url to receive the post data, and then pass the data to a controller to handle them. What about ProcessWire ? Do I have to create a template, then a page with this template (to have an url) and then handle the data from the php file associated to the template? It seems a bit of an overkill. Actually, my question boils down to : I have a php file handling some logic, how can I create a custom route to this file? Again, many thanks to everyone who answered me so far. Edited October 15, 2023 by TomPich Add some details Link to comment Share on other sites More sharing options...
bernhard Posted October 15, 2023 Share Posted October 15, 2023 1 hour ago, TomPich said: Do I have to create a template, then a page with this template (to have an url) and then handle the data from the php file associated to the template? It seems a bit of an overkill. This has been the case until we got Url Hooks in 03/2021 ? Quote This feature request originally came thanks to Bernhard. He also helped me focus in on a direction for it. As I understand it, his interest in and request for this originated from a desire for his modules to provide features at specific URLs without the module having to create and maintain custom pages, templates, fields, etc. for the purpose. And without the module having to hack around PW's 404 process. I thought that was a really good point. In fact, I think this ability to hook and handle ProcessWire URLs opens a lot of possibilities for 3rd party modules. Modules can now handle any URLs they want without having to create a page, template, template file or fields for them. Imagine an XML sitemap module that automatically responds to the /sitemap.xml URL, for example. Imagine modules being able to provide web services, documentation or examples at whatever URLs they were developed or configured to use. Yes, maybe you could do some of this before by hacking around a bit, but it was a lot more difficult. Now it's really easy, and a native part of the system. ? PS: Also have a look here: 1 Link to comment Share on other sites More sharing options...
TomPich Posted October 15, 2023 Author Share Posted October 15, 2023 (edited) Like I said, pure gold... ? Thanks Bernhard. I’ll dive into it. Edit : OK so I tried it, and it worked like a charm ! ? Edited October 15, 2023 by TomPich It worked 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now