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

jdelaune’s picture

Status: Active » Needs review
StatusFileSize
new548 bytes

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

dboulet’s picture

The patch does seem to help, subscribing.

steven jones’s picture

Title: No URL rewriting going on? » No URL rewriting in Purl for D7
Priority: Normal » Critical
Status: Needs review » Needs work

We're seeing this too.

It's down to _drupal_bootstrap_full() calling:


drupal_theme_initialize();
module_invoke_all('init');

drupal_theme_initialize() contains a call to: url() which of course runs the purl_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.

steven jones’s picture

StatusFileSize
new1.44 KB

Right, 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.

steven jones’s picture

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

mototribe’s picture

Subscribe

jon pugh’s picture

Patch 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!!

jdelaune’s picture

Status: Needs work » Reviewed & tested by the community

#4 Works great. Lets get this committed.

tobby’s picture

Patch applied and committed for beta 1.

steven jones’s picture

Status: Reviewed & tested by the community » Fixed
steven jones’s picture

Status: Fixed » Needs work

The code for the other processors probably needs to get updated too.

mrfelton’s picture

Not sure why this was ever marked as fixed in #10 as nothing has been committed. The patch in #4 does seem to work though.

jdelaune’s picture

Status: Needs work » Closed (fixed)
mrfelton’s picture

Status: Closed (fixed) » Active

@ jdelaune - it was committed, but where? Not on the 7.x-1.x branch thats for sure.

webflo’s picture

It's committed to 7.x-1.0-beta1, that's wrong. Needs clean-up.

moshe weitzman’s picture

Status: Active » Closed (fixed)

Looks like this was committed to 7.x-1.x branch today.