Welcome Guest, Not a member yet? Register   Sign In
Controller Names with Dashes or Underscores?
#12

[eluser]aidehua[/eluser]
Forget search engine friendliness for a minute. I think

Quote:example.com/about-us
is more human-friendly than

Quote:example.com/about_us

For now I'm using routes to achieve this:

Code:
$route['about-us'] = "about_us";

But it could get tedious if I have dozens of pages to set up like that:

Code:
$route['about-us'] = "about_us";
$route['contact-us'] = "contact_us";
$route['terms-and-conditions'] = "terms_and_conditions";
etc.

(You might say that these are trivial examples, and the pages could simply be re-named "about", "contact", and "terms" with no loss of usability - but there will be cases when I really do want to keep the dashes in the URI.)

And what if I'm creating pages (and URIs) dynamically through a content management system? Should I be writing a new line to my routes.php file automatically when I create a new page through the CMS? That feels a bit clunky.

If I were clever with regular expressions, maybe I could write something in routes.php that does this:

Code:
$route['[string-with-dashes-in-first-or-second-uri-segment'] = "[string-with-underscores-in-first-or-second-uri-segment]";

But I'm not clever with regular expressions.

(Anyone?)

Or would it be better to do this by customising the router library?


Messages In This Thread
Controller Names with Dashes or Underscores? - by El Forum - 05-16-2009, 09:34 AM
Controller Names with Dashes or Underscores? - by El Forum - 05-16-2009, 09:42 AM
Controller Names with Dashes or Underscores? - by El Forum - 05-16-2009, 10:13 AM
Controller Names with Dashes or Underscores? - by El Forum - 05-16-2009, 10:48 AM
Controller Names with Dashes or Underscores? - by El Forum - 05-16-2009, 10:56 AM
Controller Names with Dashes or Underscores? - by El Forum - 05-16-2009, 11:03 AM
Controller Names with Dashes or Underscores? - by El Forum - 05-16-2009, 11:11 AM
Controller Names with Dashes or Underscores? - by El Forum - 05-16-2009, 11:13 AM
Controller Names with Dashes or Underscores? - by El Forum - 05-16-2009, 11:32 AM
Controller Names with Dashes or Underscores? - by El Forum - 05-16-2009, 11:37 AM
Controller Names with Dashes or Underscores? - by El Forum - 05-16-2009, 11:38 AM
Controller Names with Dashes or Underscores? - by El Forum - 01-15-2010, 05:35 AM
Controller Names with Dashes or Underscores? - by El Forum - 03-13-2010, 06:00 PM
Controller Names with Dashes or Underscores? - by El Forum - 03-16-2010, 12:31 AM
Controller Names with Dashes or Underscores? - by El Forum - 06-18-2010, 07:24 AM
Controller Names with Dashes or Underscores? - by El Forum - 08-08-2011, 07:14 AM



Theme © iAndrew 2016 - Forum software by © MyBB