As far as I can tell this isn't an issue with my plugin module but I've included the code before just incase it is.
The provider callback is being called correctly on incoming urls containing the modifiers. However no outbound URLs are re-written so that the modifier is passed along.
Is there something I am doing wrong. Tried with a completely fresh install of Drupal 7.7 but no luck.
/**
* Implements hook_purl_provider().
*/
function ai_purl_purl_provider() {
return array(
'ai_ministry' => array(
'name' => t('AI Ministry'),
'description' => t('Returns a Ministry ID from Alias.'),
'callback' => '_ai_active_context',
'example' => 'student',
),
);
}
/**
* Implements hook_purl_modifiers().
*/
function ai_purl_purl_modifiers() {
return array(
'ai_ministry' => array(
array('value' => 'student', 'id' => 1),
array('value' => 'youth', 'id' => 2),
),
);
}
function _ai_active_context($id) {
drupal_set_message($id);
}
Comments
Comment #1
jdelaune commentedWell attached is a bug which fixes the issue, there may be a better place to solve this as I'm not sure what $global_elements initially gets set. But at least you'll know where to look.
Comment #2
dboulet commentedThe patch does seem to help, subscribing.
Comment #3
steven jones commentedWe're seeing this too.
It's down to
_drupal_bootstrap_full()calling:drupal_theme_initialize()contains a call to:url()which of course runs thepurl_url_outbound_alter()hook implementation.This statically caches the elements to add to URLs as they are altered, but this has run before
purl_init()so there purl hasn't parsed the URL for it yet.When
purl_init()does get called, purl sets itself up and calls the specific callbacks etc.The patch in 1 doesn't fix the issue for us.
Comment #4
steven jones commentedRight, so it turns out that D7 added a 'prefix' option to the url options array, which purl should be using instead of altering the actual path, this is because path aliases always take precedence over the altered path, so even after purl has altered the path, if the path has an alias, it will get changed back.
I've attached a patch that fixes up the path modifier, but the other modifiers will need fixing accordingly.
This works for me, except that Drupal core's language url re-write callbacks will wipe out the prefix if its set, which is very lame. I will raise a Drupal core issue for this.
Comment #5
steven jones commentedI've raised the bug in Drupal core: #1270894: Test that it is possible to use path prefixes in combination with language prefixes
And have a sandbox project which implements a workaround for those that don't want to patch core: http://drupal.org/sandbox/darthsteven/1270906
Both largely untested.
Comment #6
mototribe commentedSubscribe
Comment #7
jon pughPatch in comment #4 works as advertised.
Would really suggest committing this to a 7.x release soon... PURL and Spaces are pretty much useless without the menu link rewriting.
Thanks!!
Comment #8
jdelaune commented#4 Works great. Lets get this committed.
Comment #9
tobby commentedPatch applied and committed for beta 1.
Comment #10
steven jones commentedComment #11
steven jones commentedThe code for the other processors probably needs to get updated too.
Comment #12
mrfelton commentedNot sure why this was ever marked as fixed in #10 as nothing has been committed. The patch in #4 does seem to work though.
Comment #13
jdelaune commentedYes it was. http://drupalcode.org/project/purl.git/commit/781b6d2
Comment #14
mrfelton commented@ jdelaune - it was committed, but where? Not on the 7.x-1.x branch thats for sure.
Comment #15
webflo commentedIt's committed to 7.x-1.0-beta1, that's wrong. Needs clean-up.
Comment #16
moshe weitzman commentedLooks like this was committed to 7.x-1.x branch today.
Comment #17
moshe weitzman commentedhttp://drupalcode.org/project/purl.git/commit/136c79eee6cd1792bc6bf912e6...