I’d like to get around the default url path behavior where paths are mapped to template groups and templates. We have a number of existing paths that have to be migrated over to EE. These include full channels, filtered channels, single channel entries, etc. We also want to use our own url scheme for future SEO purposes. This would be more akin to Drupal-like or pure MVC url handling where urls are mapped to behavior, rather than templates (how EE and Wordpress operate).
We want to avoid 301 redirects for the existing content. I’ve seen that the Pages module can be used for a single entry, which we may use in some cases. However there remains the majority of our urls like any of the following
/wedding-dresses : full channel index page /wedding-dresses/a-line : filtered channel by a single custom field /wedding-dresses/designer/davids-bridal : filtered channel by designer (relationship) /wedding-dresses/search/?x=35&y=21&tags;[Style]=3&tags;[Embellishment]=44 : channel with many filters
What I think I want is a way to use an extension hook to look at urls before execution or just before a 404 response, decide which channel content to show and render a specific template. Is this possible?
I want to avoid doing a lot of url aliasing logic and embedded template rendering within a 404 template. To me that isn’t an appropriate course for separation of logic.
Edit: I’ve found the Detour extension which does a simple lookup at session start. This is a useful stepping stone. The remaining question is the best path to take to instruct from the extension which channel content to load and which template to render.
Hi there
You could use segment conditionals to your advantage here. Keeping your conditionals “simple” would make something like this effective/possible:
Assuming the url options you provided.
{if segment_2 == ''}
-- empty segment 2 means we use our full channel index code --
{/if}
{if segment_2 == 'designer'}
-- segment triggers designer filter code --
{/if}
{if segment_2 == 'search'}
-- segment triggers search mode with $_GET var usage (which would probably require an add-on for optimal performance) --
{/if}
...etc...There are many ways to achieve this. It will just depend on your needs ultimately. I like the idea of starting from a set of URLs and URL structures then working toward a template group / template approach from there.
There must be a better way to do routing than in a template with a bunch of {if} statements and embeds. It seems like such a bad method. I’d be happy with a module that looks at the url and says “hey, you should render x/y.html”.
One major problem is we want one search results page that shows content filtered depending on the url. The urls are like this
/wedding-dresses/embellishment/sash /wedding-dresses/embellishment/beading /wedding-dresses/embellishment/lace
It’d be repetitive and unwieldy to create multiple Page entries that all link to one template.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.