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

q0rban’s picture

subscribe

puddyglum’s picture

I 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.

IceCreamYou’s picture

There'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.

MXT’s picture

Sorry 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

mattsmith3’s picture

Another 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.

jorisx’s picture

Issue summary: View changes

It 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

deanflory’s picture

Is this 5 year old issue still an issue?

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

lauriii’s picture

Version: 8.1.x-dev » 7.x-dev
Assigned: Dave Reid » Unassigned

I'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