Skip to content

Instantly share code, notes, and snippets.

@nicksantamaria
Created June 8, 2011 05:06
Show Gist options
  • Save nicksantamaria/1013816 to your computer and use it in GitHub Desktop.
Save nicksantamaria/1013816 to your computer and use it in GitHub Desktop.
Psuedo-code for getting the parent page's title when using urls as hierarchy
<?php
// Get the requested URL alias and explode into array
$q = trim($_SERVER['REQUEST_URI'], '/');
$arg = explode('/', $q);
// Shorten the URL by 1 argument
$newArg = array_slice($arg, 0, (count($arg) - 1));
// Get the menu item for the new URL
$item = menu_get_item(implode('/', $newArg));
// Here is the title
$title = $item['title'];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment