Skip to content

Instantly share code, notes, and snippets.

@mglaman
Last active January 16, 2016 20:45
Show Gist options
  • Save mglaman/e5d7a03e22d9d4f8c288 to your computer and use it in GitHub Desktop.
Save mglaman/e5d7a03e22d9d4f8c288 to your computer and use it in GitHub Desktop.
Messing with inbound/outbound
<?php
/**
* Implements hook_url_inbound_alter().
*/
function muimodule_url_inbound_alter(&$path, $original_path, $path_language) {
if (preg_match('/^(.*)\/news$/', $path, $matches)) {
$node_path = $matches[1];
$conditions = array('alias' => $node_path);
$actual_apth = path_load($conditions);
if ($actual_apth !== FALSE) {
$path = $actual_apth
}
else {
throw new Exception('FUCKING SHIT');
}
}
}
/**
* Implements hook_url_outbound_alter().
*/
function muimodule_url_outbound_alter(&$path, &$options, $original_path) {
if (preg_match('/^node\/([0-9]+)\/news$/', $path, $matches)) {
$conditions = array('source' => 'node/' . $matches[1]);
$path = path_load($conditions) . '/news';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment