Related content types and routes

Topics: Writing modules
May 9, 2015 at 2:01 AM
I need some development advice.

I have a site that has territories and manufacturers. Each manufacturer can be in one or more territories. A user starts by clicking on a territory, then a list of manufacturers is displayed. I'd like to capture the territory the user entered through in the route and as a variable on the server to filter the display of other content items.

When a user selects a territory the route should be.

http://mysite.com/territory-x

Then when a user clicks a manufacturer the route should be

http://mysite.com/territory-x/manufacturer-abc

What's the best way to do this given Orchard's framework? I am using the autoroute module currently.

Thanks in advance. Please let me know if I need to clarify further.
May 15, 2015 at 5:15 PM
Just pinging for a response. Can anyone provide direction? Thanks.
Developer
May 16, 2015 at 1:18 PM
One way could be to leverage the taxonomies feature, where a Territory is a Term of the Territory taxonomy.
You would basically tag your manufacturers with Territory terms.
The AutoroutePart route pattern on the Manufacturer type would then have to be configured to generate an alias based on the slug of the term (Territory) plus the slug of the manufacturer item. That route would look something like: "{Content.Fields.Manufacturer.Territory.Terms:0.Slug}/{Content.Slug}".

Another way this could be done is by using the ContainerPart and ContainablePart, where your Territory type would have the ContainerPart and configured to hold Manufacturer items, and your Manufacturer type would have the ContainablePart. Then the AutoroutePart for the Manufacturer type would have its route pattern configured to something like: "{Content.Container.Slug}/{Content.Slug}".

And then there's always the option of implementing a custom controller, action and route provider.
Jun 16, 2015 at 2:11 AM
This was helpful. Thank you.