From an older issue:
#284484: disable pathauto for one or more types of nodes

Hi,
I can't seem to find how to disable pathauto for different node types, specifically project and project release...
I'm pretty sure this is possible but can't seem to find how to do it.

I suggest we introduce a <none> pattern for explicit disabling.

Related

Doc: "When the pattern for a node type is left blank, the default pattern will be used. But if the default pattern is also blank, Pathauto will be disabled for that node type."
-> not a solution. We want to distinguish between "intentionally disabled for this type" and "noone cared enough to define a pattern for this, so we use the default."

"adding the pattern UI to the content type forms."
-> this would be nice, but would not be a sufficient solution to this particular problem. Let's discuss this elsewhere.

#273104: Using "progressive disclosure" for alias patterns
-> would be nice, but would not be a sufficient solution.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

donquixote’s picture

Title: Disable pathauto for one or more types of nodes » Introduce a &lt;none&gt; pattern to explicitly disable pathauto (e.g. for specific node types)
donquixote’s picture

Title: Introduce a &lt;none&gt; pattern to explicitly disable pathauto (e.g. for specific node types) » Introduce a <none> pattern to explicitly disable pathauto (e.g. for specific node types)
donquixote’s picture

Wow, that's supereasy to implement.
If you want I can produce a patch. Please tell me if I need to start with D7 or D6.

For now, here is what I changed in D6.

In function _pathauto_validate_pattern_element():

<?php
  if (!drupal_strlen($value)) {
    return $element;
  }
?>

becomes

<?php
  if (!drupal_strlen($value) || $value == '<none>') {
    return $element;
  }
?>

In function pathauto_create_alias():

<?php
  // No pattern? Do nothing (otherwise we may blow away existing aliases...)
  if (empty($pattern)) {
    return '';
  }
?>

becomes

<?php
  // No pattern? Do nothing (otherwise we may blow away existing aliases...)
  if (empty($pattern) || $pattern == '<none>') {
    return '';
  }
?>
donquixote’s picture

I wonder if we need to trim($value) on form submission.

donquixote’s picture

Btw1, if you rather prefer a checkbox than a <none> pattern..
We could still store the <none>, but display a checkbox.

Btw2, the <none> would currently not validate, so we do not need to worry about people who actually want <none> as the alias :)

donquixote’s picture

Status: Active » Needs review
FileSize
930 bytes

The D6 patch (D7 will follow)

donquixote’s picture

Version: 6.x-2.x-dev » 7.x-1.x-dev
FileSize
1.66 KB

Nice. Now D7.
"untested", because I did not actually try the D6 -dev release or anything of D7.

jumpbug’s picture

I was looking for this and #3 was a solution, thanks!

Jim Kirkpatrick’s picture

I love the idea of but for me that should override the existing alias, including deleting it IF the pathauto settings are set to 'create new alias, delete old one'...

If I check nodes in the content management page and run the 'update url alias' action, I should expect any with pattern of '' to be unaliased and cleansed the alias table of unwanted entries if my PA settings say so.

Do these patches behave this way? They should IMHO...

JordanMagnuson’s picture

Is there a reason this has not been implemented in the last year and a half?

jantoine’s picture

Patch in #7 is fantastic! It even removes the "generate" checkbox when '' is set for the pattern. Code comments might need work to meet Drupal coding standards, but this is a great starting point. I am guessing this hasn't been implemented because after five years of working with Drupal, I am just now needing it ;)

wvd_vegt’s picture

Hi

Just checked and an alias of

node/[node:nid]

does not generate an alias. It also does not need a patch.

It generates a message though

•Ignoring alias node/536 because it is the same as the internal path.

donquixote’s picture

jason.fisher’s picture

Applied successfully here to the latest 7.x-dev.

jason.fisher’s picture

Issue summary: View changes

explain why the default blank-blank is not a solution.

SiliconMind’s picture

blank-blank solution is poor because it requires you to provide ALL patterns explicitly (except default). If you add new content type, then you also have to provide a new pattern explicitly.

andyhu’s picture

Issue summary: View changes

I really hope this could be implemented. It's very useful!

jimmyko’s picture

Why no one follow?

jmuzz’s picture

+1 #7 works for me.

xstean’s picture

Looks like no one noticed what wvd_vegt said
He's right, if you write the original path has pattern, Drupal wont generate a new one.

So, for nodes you should set node/[node:nid]
For users: users/[user:uid]

You don't need a patch, just try it :)

Thanks a lot wvd_vegt

rooby’s picture

While #12 may be a viable work around, I think the explicit option as per the patch is the preferable solution.

rooby’s picture

Functionally it works for me.
Here is a reroll with node & comment numbers in the file name that applies to latest dev. No code was changed except a minor change to the docblock of the validation callback.

The only thing that I think would be a good addition would be some help text somewhere that tells users that <none> is a possibility.

Status: Needs review » Needs work

The last submitted patch, 21: pathauto-none_pattern-1218952-21.patch, failed testing.