0

I have three templates, and three routes in my template group as follows:

  • courses -- index (landing page) -- filtered (filtered listing) -- details (course details)

And I want to have the following relevant url structure:

/courses/

/courses/type/undergraduate/

/courses/type/undergraduate/course_name/

And I have set the following routes:

template group/template == route

courses/index == nothing in here

courses/filtered == /courses/{filter:alpha_dash}/{filter2:alpha_dash}

courses/details == /courses/{filter:alpha_dash}/{filter2:alpha_dash}/art/

both 'filtered' and 'details' have segments required.

so.....

/courses

gives me courses landing page no probs, I would expect that, reading from the index template as default behaviour.

/courses/type/undergraduate

gives me back the filtered course type filtered to 'type', 'undergraduate' which is read from the filtered template.

/courses/type/undergraduate/art

gives me back course details for art, reading from the details template, as I expect.

But the problem comes when I put this into my route, adding the course name as the trigger to dynamically shift the the details template as I would expect (as opposed to the hard-coded value 'art'):

/courses/{filter:alpha_dash}/{filter2:alpha_dash}/{coursename:alpha_dash}

When I refresh this: /courses/type/undergraduate/art

I get the following error, plus my template reverts back the initial landing template of the index in the group.

A PHP Error was encountered

Severity: Warning Message: preg_match_all(): Compilation failed: group name must start with a non-digit at offset 166 Filename: libraries/Template_router.php Line Number: 56

So am I missing the point of routes, or is there some bug in the machine here?

EE version 2.9.0 is the flavour I am playing with.

1 Answer 1

1

I was just struggling with this problem, everything I was doing was resulting in the same error. I fortunately just managed to fix it though, problem is I'm not 100% sure why it happened I just know that it did.

Open up the following file: system > expressionengine > libraries > template_router and open up Route.php

Find the following line of code: $hash = md5($variable); And change it to:

$hash = md5($variable);
$hash[0] = 'r';

Save and reupload the file.

Link to EllisLab bug

If you then go to CP > Home > Design > Template Manager > Template Route Manager you will see a list of all your templates and routes.

Create all your templates with no forward slash at the beginning (this worked for me but not sure if it's because my site url has a trailing forward slash at the end).

Where you want to have your multiple variable segments use the following;

courses/type/{type:alpha_dash}/{coursename:alpha_dash}

And make sure that Segments Required is unticked!

Now hit update and you should be good to go.

I've just restructured the answer as I believe this to be the correct path to fixing the issue. The 2nd part is probably still worth doing just for sake of consistency.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.