1

Good evening folks,

I recently enquired what the best way to build a UGC site using ExpressionEngine would be. I decided to go down the route of a custom module and that side of things is now working: a table is being created, users are able to add jobs from a form on the front end and there are tags available for me to use in my templates to 'list' and 'single' jobs.

However, I still can't get my head around the EE URL structure.

The site has a number of top-level sections which each of the listing types fall under. The example I gave in the previous post was 'jobs' but this actually falls under the 'opportunities' section. Therefore, the URL structure I'm trying to achieve is:

/opportunities/jobs/                           jobs listing page
/opportunities/jobs/*id*-*job-title*/          job single page
/opportunities/jobs/add/                       add job page
/opportunities/jobs/edit/*id*-*job-title*/     edit job page
/opportunities/jobs/delete/*id*-*job-title*/   delete job page
/opportunities/jobs/success/                   success page for add/edit/delete job
/opportunities/jobs/filter/today/              jobs posted today          
/opportunities/jobs/filter/this-week/          jobs posted in last 7 days
/opportunities/jobs/filter/2013/oct/           jobs posted in october 2013
...                                            (previous 12 months)
/opportunities/jobs/filter/2012/nov/           jobs posted in november 2012
/opportunities/jobs/filter/archive/            (including those with a status of 'closed')

I'm baffled as to whether this URL mapping is something that I would build into my module (in which case, could someone please point me in the direction of documentation as I can't find anything about it anywhere...) or whether I'd just create an 'opportunities' template group and the use the 'index' template as a controller to embed the correct sub-template (based on {if} statements checking the value of the third segment).

Or, is this a job for Router, or even some good old .htaccess rules?

Many thanks, as always, for any advice.

Edit: I've found the pages module, which allows me to add a page with the URL /opportunities/jobs but then /opportunities/jobs/add returns a 404. I doubt this is the correct route as it re-introduces the problems I originally faced when using Structure...

0

This is definitely something that will be difficult without some add-ons. As your edit suggests, the Pages Module is great for getting custom URLs, but breaks down as soon as you try to add dynamic segments to the URLs. It works very similarly to Structure, so that's not going to be your solution here.

I think your best bet would be to check out Rob Sanchez' Template Routes add-on. I personally have never used it, but it seems like it should help you customize your URL structure to match the scheme you're looking for.

| improve this answer | |
  • Thanks for your answer Jeremy. I'm surprised that there isn't a way to define the custom routes within the module that I'm writing. This would make most sense as it would mean that the module was entirely self-contained and could therefore be distributed and used without any additional plugin requirements. I was considering attempting to modify the default controller (as outlined here: venodesigns.net/2011/05/07/…) but even that requires alterations to index.php and therefore moves away from the self-containment model that I"m after... – Joe Czucha Oct 6 '13 at 9:37
  • You would need to have an extension (in addition to the module) to define custom routes. Obviously if it can be done within an add-on you could do it too. I'd still recommend taking a look at Template Routes for the methodology. You're welcome to replicate it. – Jeremy Gimbel Oct 6 '13 at 15:10
  • Thanks for your feedback. The plugin does look like it will do everything I need so I'm just going to use that. No point in re-inventing the wheel and it will tide me over until EllisLabs but in a straightforward routes API. – Joe Czucha Oct 6 '13 at 15:48

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.