Last active
January 16, 2016 20:45
-
-
Save mglaman/e5d7a03e22d9d4f8c288 to your computer and use it in GitHub Desktop.
Messing with inbound/outbound
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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