Re: Router URLs: hyphens instead of underscores
congrats now you get to run str_replace on every url parsed by your app. you should really just be defining these routes in the router in the first place with dashes Router::connect('/my-links/*', array('controller' = 'my_controller', 'action' = 'my_links')); ); you should be using verbose linking(reverse routing) in your views echo $html-link('my link text', array('controller' = 'my_controller', 'action' = 'my_links')); more information about your links would be helpful in solving your problem. On Jul 27, 2:15 pm, Jamie jamie@gmail.com wrote: Alright, so what I just ended up doing was adding a bit of a hack to cake/libs/router.php and app/config/bootstrap.php. In the Router::url(), I changed the last line: return $output . $extension . $_this-queryString($q, array(), $escape) . $frag; To this: $url = str_replace('_', '-', $output . $extension . $_this-queryString ($q, array(), $escape) . $frag); return $url; Then I added this to the top of my bootstrap: $_GET['url'] = str_replace('-', '_', $_GET['url']); Total hack? You betcha. But it works for now. On Jul 27, 10:56 am, Jamie jamie@gmail.com wrote: Yes, I know this issue has been raised in the past (a long while ago), but there's been no satisfying answer yet. Basically, best SEO practices say that we should be using hyphens instead of underscores in our URLs, since search engines such as Google have an easier time parsing my-page, rather than my_page, as two separate words (and thus a distinct search term). Is it time for Cake to look at allowing hyphens instead of underscores in URLs? Before anyone says OMG you can just do this (as Nate suggested athttp://trac.cakephp.org/ticket/1727): $_GET['url'] = str_replace(-, _, $_GET['url']); that's fine for parsing incoming URLs, but it doesn't even come close to providing a solution since links generated by the Cake router (i.e. via the HtmlHelper etc.) use underscores instead of hyphens, and that's that. So for those of us who want to use hyphens instead of dashes, we need to enter manual URLs instead of using Cake's routing capabilities. So, sure, we can translate incoming links, but we can't generate the proper links in the first place. Has anyone thought of a solution? Is the Cake team contemplating adding support for multiple URL separators? Any home brew hacks out there? - Jamie --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Router URLs: hyphens instead of underscores
congrats now you get to run str_replace on every url parsed by your app. even worse when the codebase is upgraded your hack will be difficult to maintain. basically you will have to recode it every time you upgrade. best to leave the core ALONE. you should really just be defining these routes in the router in the first place with dashes Router::connect('/my-links/*', array('controller' = 'my_controller', 'action' = 'my_links')); ); you should be using verbose linking(reverse routing) in your views echo $html-link('my link text', array('controller' = 'my_controller', 'action' = 'my_links')); more information about your links would be helpful in solving your problem. On Jul 27, 2:15 pm, Jamie jamie@gmail.com wrote: Alright, so what I just ended up doing was adding a bit of a hack to cake/libs/router.php and app/config/bootstrap.php. In the Router::url(), I changed the last line: return $output . $extension . $_this-queryString($q, array(), $escape) . $frag; To this: $url = str_replace('_', '-', $output . $extension . $_this-queryString ($q, array(), $escape) . $frag); return $url; Then I added this to the top of my bootstrap: $_GET['url'] = str_replace('-', '_', $_GET['url']); Total hack? You betcha. But it works for now. On Jul 27, 10:56 am, Jamie jamie@gmail.com wrote: Yes, I know this issue has been raised in the past (a long while ago), but there's been no satisfying answer yet. Basically, best SEO practices say that we should be using hyphens instead of underscores in our URLs, since search engines such as Google have an easier time parsing my-page, rather than my_page, as two separate words (and thus a distinct search term). Is it time for Cake to look at allowing hyphens instead of underscores in URLs? Before anyone says OMG you can just do this (as Nate suggested athttp://trac.cakephp.org/ticket/1727): $_GET['url'] = str_replace(-, _, $_GET['url']); that's fine for parsing incoming URLs, but it doesn't even come close to providing a solution since links generated by the Cake router (i.e. via the HtmlHelper etc.) use underscores instead of hyphens, and that's that. So for those of us who want to use hyphens instead of dashes, we need to enter manual URLs instead of using Cake's routing capabilities. So, sure, we can translate incoming links, but we can't generate the proper links in the first place. Has anyone thought of a solution? Is the Cake team contemplating adding support for multiple URL separators? Any home brew hacks out there? - Jamie --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Router URLs: hyphens instead of underscores
Yes, I know this issue has been raised in the past (a long while ago), but there's been no satisfying answer yet. Basically, best SEO practices say that we should be using hyphens instead of underscores in our URLs, since search engines such as Google have an easier time parsing my-page, rather than my_page, as two separate words (and thus a distinct search term). Is it time for Cake to look at allowing hyphens instead of underscores in URLs? Before anyone says OMG you can just do this (as Nate suggested at http://trac.cakephp.org/ticket/1727 ): $_GET['url'] = str_replace(-, _, $_GET['url']); that's fine for parsing incoming URLs, but it doesn't even come close to providing a solution since links generated by the Cake router (i.e. via the HtmlHelper etc.) use underscores instead of hyphens, and that's that. So for those of us who want to use hyphens instead of dashes, we need to enter manual URLs instead of using Cake's routing capabilities. So, sure, we can translate incoming links, but we can't generate the proper links in the first place. Has anyone thought of a solution? Is the Cake team contemplating adding support for multiple URL separators? Any home brew hacks out there? - Jamie --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Router URLs: hyphens instead of underscores
Alright, so what I just ended up doing was adding a bit of a hack to cake/libs/router.php and app/config/bootstrap.php. In the Router::url(), I changed the last line: return $output . $extension . $_this-queryString($q, array(), $escape) . $frag; To this: $url = str_replace('_', '-', $output . $extension . $_this-queryString ($q, array(), $escape) . $frag); return $url; Then I added this to the top of my bootstrap: $_GET['url'] = str_replace('-', '_', $_GET['url']); Total hack? You betcha. But it works for now. On Jul 27, 10:56 am, Jamie jamie@gmail.com wrote: Yes, I know this issue has been raised in the past (a long while ago), but there's been no satisfying answer yet. Basically, best SEO practices say that we should be using hyphens instead of underscores in our URLs, since search engines such as Google have an easier time parsing my-page, rather than my_page, as two separate words (and thus a distinct search term). Is it time for Cake to look at allowing hyphens instead of underscores in URLs? Before anyone says OMG you can just do this (as Nate suggested athttp://trac.cakephp.org/ticket/1727): $_GET['url'] = str_replace(-, _, $_GET['url']); that's fine for parsing incoming URLs, but it doesn't even come close to providing a solution since links generated by the Cake router (i.e. via the HtmlHelper etc.) use underscores instead of hyphens, and that's that. So for those of us who want to use hyphens instead of dashes, we need to enter manual URLs instead of using Cake's routing capabilities. So, sure, we can translate incoming links, but we can't generate the proper links in the first place. Has anyone thought of a solution? Is the Cake team contemplating adding support for multiple URL separators? Any home brew hacks out there? - Jamie --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---