Token and Path Alias changes in Drupal 7
Ian Mon, 02/07/2011 - 13:45
I will preface this post with the following:
So this is a minor gripe in the big picture, and I am sure that it is all my fault.
When I upgraded from Drupal 6 to 7 it appears that all of my automatic URL Aliases stopped working. What you ask is a URL alias? When drupal creates an article, by default it gives an URL of www.mysite/node/56. In this case that means that it was the 56th piece of content to be created on the website. Using some of Drupals magic features (namely the Pathauto module) you can have:
www.mysite.com/node/56 -> turned into -> www.mysite.com/Blogs/2010/12/This-article
You can change the renaming patterns based on info that is already in the Drupal system. In the example above I am using the content type (Blogs), the year the post was created (2010), the 2 digit month it was created in (12) and the title of the post (This-Article). All of these things are already in the Drupal system, and we can use the Token module to dynamically pull the info into the process. The process really helps in making a website seem more user friendly, and in general makes it easier to navigate.
Before the upgrade to Drupal 7, the code for the url alias used to be :
Blogs/[yyyy]/[mm]/[title-raw]
After the upgrade, the code is now:
Blogs/[node:created:custom:Y]/[node:created:custom:m]/[node:title]
While I am glad that I figured it out, I wish there was a bigger warning that there was a change. I am fairly sure that there was a warning somewhere, but I missed it, and as such the syntax that I was using previously did not work after the upgrade. The Upgrade did bring a cool feature, and that is the ability to use the PHP date functions as a "custom" date token. I have taken advantage of those to grab the year and month for the path. Some of the other patterns available in the PHP date function can be found here.
So, just a heads up, if you are upgrading your site from Drupal 6 to 7, make sure you check that you pathauto patterns are still valid.

Add new comment