I'm trying to map some Wordpress paths to Drupal paths. I have a database table which has the corresponding paths and I have the following in a module, but I am getting Page Not Found. Am I using the module in the wrong way?

/**
 *Implementation of hook_boot()
 */
function hook_boot() {
 	 // Ensure this module is loaded for url_rewrite_inbound
 	 drupal_load('module', 'mymodule');
 }
 
 /**
 * Implementation of hook_url_alter_inbound()
 */
function mymodule_url_alter_inbound(&$result, $path, $path_language) {

// Map old wordpress aliases to Drupal internal paths
  $query= db_query("SELECT src, dst FROM {mymodule_url_alias}");
  while ($row = db_fetch_object($query)) {
  	if ($path == $row->dst) {
  		$result = $row->src;	
  		}
  }
}

Comments

dave reid’s picture

Status: Active » Fixed

First, make sure the first function is mymodule_boot(). And it can just be empty, you don't need to run drupal_load().

Second, I'd probably do something like this with the url_inbound_alter (note the change of name) function:

function mymodule_url_inbound_alter(&$result, $path, $path_language) {
  if ($old_path = db_result(db_query_range("SELECT src FROM {mymodule_url_alias} WHERE dst = '%s'", $path, 0, 1))) {
    $result = $old_path;
  }
}

Status: Fixed » Closed (fixed)

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