Handling pretty URLs with single pages
Permalink
Hi All,
I'm looking for some tips of how to use querystring variables to power my single page, but have those variables "pretty".
Currently I have a single page for job listings, which reads from an external data source. This links to job detail pages, all powered from the one single page.
I have it setup so that example.com/jobs/?jobid=123 loads a single job listing. I would like this to be example.com/jobs/123/ or example.com/jobs/123-web-developer/
Basically looking for a way to bind these URL patterns to my single page. Is anyone able to advise on this please?
I'm looking for some tips of how to use querystring variables to power my single page, but have those variables "pretty".
Currently I have a single page for job listings, which reads from an external data source. This links to job detail pages, all powered from the one single page.
I have it setup so that example.com/jobs/?jobid=123 loads a single job listing. I would like this to be example.com/jobs/123/ or example.com/jobs/123-web-developer/
Basically looking for a way to bind these URL patterns to my single page. Is anyone able to advise on this please?
So if you have a single page at /mysite/jobs/
By default, function view() in the controller for jobs will be called.
If you now have a path
/mysite/jobs/category/subcategory/,
and view has a couple of parameters:
Then this path will also map to view(), but only if view() has enough parameters to accept the additional parts of the path and only if you don't also have an action function or page /mysite/jobs/category/ which the C5 dispatcher will give precedence to.
You can't just pull them out of the arguments array because the C5 dispatcher decides based on declared parameters. On the other hand, you can declare a long list of parameters just in case, to grab whatever path may be thrown at the function in your jobs single page controller: