Where to implement custom routing code
Permalink
Hello there,
I'm currently implementing a c5 site that has different content depending on the region, and the region is dictated by subdomain, eg en.example.com, or fr.example.com
Now I've divided the content up into different regions in the site map, and have written a bunch of vhost rules that set an environment variable dictating the required region. All I need to do is modify the routing so that concrete 5 loads example.com/en when I go to en.example.com. (please note that due to DNS restraints on the main domain, simply using subfolders or redirecting is impossible).
Currently, I've added the following code to the parsePathFromRequest function in the request class located at concrete/core/libraries/request.php:
Now as a proof of concept, this seems to be working absolutely fine. The problem is, (and I'm sure you'd all agree) that editing the core is inherently a bad idea. So I was just curious as to where I should implement this code? Is there some sort of event hook I can use, or would I have to override the file entirely?
It might be worth noting that the site will only be live for a few months, so maintainability and upgrade-ability are not particularly massive concerns.
I'm currently implementing a c5 site that has different content depending on the region, and the region is dictated by subdomain, eg en.example.com, or fr.example.com
Now I've divided the content up into different regions in the site map, and have written a bunch of vhost rules that set an environment variable dictating the required region. All I need to do is modify the routing so that concrete 5 loads example.com/en when I go to en.example.com. (please note that due to DNS restraints on the main domain, simply using subfolders or redirecting is impossible).
Currently, I've added the following code to the parsePathFromRequest function in the request class located at concrete/core/libraries/request.php:
Now as a proof of concept, this seems to be working absolutely fine. The problem is, (and I'm sure you'd all agree) that editing the core is inherently a bad idea. So I was just curious as to where I should implement this code? Is there some sort of event hook I can use, or would I have to override the file entirely?
It might be worth noting that the site will only be live for a few months, so maintainability and upgrade-ability are not particularly massive concerns.