I have a case where occasionally the alias fails to be generated (node title ends up being empty in the token replacement). I would like to act on that event and add some special logic to create my own automatic alias. Attached is a patch that proposes a solution by adding another alter hook as a second chance.

Is there an easier way to do this? If not, would you consider adding this to the module?

Thx!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Dave Reid’s picture

I'm not sure about the feasibility of this. What if instead we allowed you to alter $pattern before token replacement is performed ala hook_pathauto_pattern_alter(&$pattern)?

Kevin Hankens’s picture

Thx for the quick reply! That would be a great fix for me personally. New patch attached for general perusal.

Kevin Hankens’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, pathauto_retry-1565850-2.patch, failed testing.

Dave Reid’s picture

I was thinking something more like this.

Kevin Hankens’s picture

That could work. If I call token_replace() from within that hook I can test to see if the alias will be empty when it is officially generated. It's a bit of an estimation, but that should be ok.

Plus, I really really like the idea of having more control over the patterns themselves!

Kevin Hankens’s picture

Status: Needs work » Needs review
Kevin Hankens’s picture

Just checking back on this one. What is the next step to get this patch in? Do you need more eyeballs on it first?

Thx!

Dave Reid’s picture

Title: Allow modules to respond to a failed path creation » Add a hook_pathauto_pattern_alter() that runs before token replacement in pathauto_create_alias()
Assigned: Unassigned » Dave Reid

Re-titling and preparing for commit.

Dave Reid’s picture

Revised final patch.

Dave Reid’s picture

Version: 7.x-1.x-dev » 6.x-2.x-dev
Status: Needs review » Patch (to be ported)

Pushed #10 to 7.x-1.x. Marking as needs to be backported to 6.x-2.x. http://drupalcode.org/project/pathauto.git/commit/fb961c0

Dave Reid’s picture

Issue summary: View changes
Status: Patch (to be ported) » Needs review
FileSize
2.74 KB

Patch against 6.x-2.x.

Dave Reid’s picture

Status: Needs review » Fixed
Dave Reid’s picture

Version: 6.x-2.x-dev » 7.x-1.x-dev

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

rudiedirkx’s picture

Please create a new release. It's been 3 years. It's about time these goodies are actually usable.

rudiedirkx’s picture