Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
We have a DX problem that drupal_get_path_alias() does not invoke hook_url_outbound_alter() while drupal_get_normal_path() does invoke its respective own hook_url_inbound_alter(). Modules like Sub-pathauto which rely on being able to run hook_url_outbound_alter() are unable to affect functions like block visibility settings which uses drupal_get_path_alias().
I propose that we move the invocation of hook_url_outbound_alter() from url() to drupal_get_path_alias().
Comments
Comment #1
q0rban CreditAttribution: q0rban commentedsubscribe
Comment #2
puddyglumI would REALLY like to see this as well. Right now other modules (path_alias_xt) rely on the developer to use php runkit or modify core. Neither of those options are safe to use in our environment, so we're kinda stuck doing things the long, hard way.
What we want is the ability to replace node/123/edit with my-alias-here/edit, and allow Blocks to use my-alias-here* for visibility.
Comment #3
IceCreamYou CreditAttribution: IceCreamYou commentedThere's a little bit of a challenge here because url() has more information about the full URL requested than drupal_get_path_alias(). hook_url_outbound_alter() currently gets the $path as well as the $options array which includes things like the query parameter, whether the link is external, etc. whereas drupal_get_path_alias() only has the $path without those options. Also drupal_get_path_alias() only gets called for URLs that need aliasing whereas currently hook_url_outbound_alter() gets called regardless of whether the URL gets aliased. I'm not sure what the right solution is, but we should probably define more clearly what hook_url_outbound_alter() is (used) for and compare that to the functionality that this issue needs.
Comment #4
MXTSorry guys, any news on this? I'm using sub-pathauto in many sites and still I can't properly set block visibility in sub-pathauto url aliases...
Thank you very much for considering this
Comment #5
mattsmith3 CreditAttribution: mattsmith3 commentedAnother vote for addressing this. Subpathauto and it's preservation of SEO friendly url's is a significant pursuit for Drupal, and providing support (or a proposed alternative) for this would benefit many. I'll keep an eye on this issue, and help however I can.
Comment #6
jorisx CreditAttribution: jorisx commentedIt would be great to see any news or solutions to this issue :)
Anyone any updates or a work around?
... update:
it works better with: Extended Path Aliases https://www.drupal.org/project/path_alias_xt
and there is a fix for the wild card: https://www.drupal.org/node/850908
But eventually I used context to show the block visibility on views and menu patterns.
so the core fix was not needed
Comment #7
deanflory CreditAttribution: deanflory as a volunteer commentedIs this 5 year old issue still an issue?
Comment #9
lauriiiI'm pretty sure this issue doesn't exist anymore in the Drupal 8 since everything related to this has changed drastically. Moving back to 7.x