This patch adds the following functionality:

If the path alias field is left empty, a path alias will automaticly be generated from the title.

A setting to activate/inactivate this function is also added.

(It is tested with version 4.5, but for some reason I can only choose 4.2.0 when submitting.)

CommentFileSizeAuthor
path.module.patch4.28 KBTommy Sundstrom

Comments

jhriggs’s picture

Project: Path » Drupal core
Component: Code » path.module

You can only choose through 4.2, because it was added to Drupal core after that. Be sure to set the status to patch if you attach one.

Recategorizing and setting to patch...

matt westgate’s picture

Many folks have asked for this sort of functionality, but I'm not convinced it should live in Drupal core. The changes you've made could be put in a new title_alias module since *_nodeapi is invoked for every module that references it.

Tommy Sundstrom’s picture

It's such a small functionality - does it realy merit a module of it's own?

I fear that if small functions like this gets there own module, the number of modules will soon be unpractical.

On the other hand, you may have a point. There is many different ways to transform a title into a path. I've done it one way, but I'm sure other people would prefere to have it done some other way. If it's a module of it's own, not a part of the core, it would be easier to provide alternatives.

But I'm new to this, and still trying to learn the Drupal style, so if more people agree that your suggestion is the more drupalish way to do it, I'll try to make it into a separate module.

kbahey’s picture

I think this functionality is really good. A separate module is overkill. It belongs to the existing path module.

I for one, always alias my nodes with something that is the approximation of the taxonomy term, then a / then the title, separated with dashes, and having .html appended at the end.

So, the node titled : "Microsoft Internet Explorer vs. Mozilla Fire Fox" would be:
technology/microsoft-internet-explorer-vs-mozilla-fire-fox.html

Taxonomy terms are already aliased, so term/123 is already 'technology'.

So, if you could add an option for "Prepend taxonomy alias to node alias", and "add custom suffix" (configurable, e.g. .html) that would really great.

The .html in the alias will tell me immediately if this is a node or a taxonomy term if I need mass manipulation in the database via scripts, ..etc.

Thanks for that functionality! Great work.

Tommy Sundstrom’s picture

I've concidered the option to prepend a taxonomy term. But how should it behave when several taxonomy terms is selected? Take one at random? Append them all? (I don't want to add complexity in the edit form by asking the user to choose).

Why a suffix? It has no practical implication, a page in Drupal will serve just as well with or without the .html suffix. Is it just nostalgical reasons, or is there any functional need behind your request?

Tommy Sundstrom’s picture

Sorry, I missed your last paragraph where you state the reason.

killes@www.drop.org’s picture

I really think this I the kind of feature that should be implemented in a contrib module. There you have a lot more freedom which features to implement and which not.

nolageek’s picture

Does the core have this functionality? I would really like drupal to, instead of having permalink URLs like drupal/node/215 I'd like it to create aliases like drupal/vocabulary/term/node-title automatically. Is this similar to what this patch does?

chrisada’s picture

I'm also of the opinion that this should live in a contrib module. Think, for example, how to deal with non-latin title? I'm not sure how many % of Drupal site out there will benefit from this, and how many will have problem with it. So probably contrib module is the best place, for now.

nolageek’s picture

However it gets done, I think this is important. I've been checking out other CMS systems, and Drupal is the only one who's URLs are so cryptic. The URLs Drupals should be more descriptive. Sure, it should be left to the admin, but node/234234 says nothing about the page you're reading and I think it's good accesibility that the url be a breadcrumb to what you're reading.

Right now I have several windows up with drupal, bricolage, typo3, MT, Wordpress, Nuke, Zope, opencms, midguard, Mambo and slashdot driven sites.

Only Drupal lacks clear category/taxonomy based urls to articles.

Just a thought.

Tommy Sundstrom’s picture

I've cleaned up, extended and moved the code to a module: http://drupal.org/node/14698

Please continue the discussion there.