Skip to content

Instantly share code, notes, and snippets.

@nigelheap
Forked from nicksantamaria/gist:1013816
Created June 8, 2011 05:08
Show Gist options
  • Save nigelheap/1013819 to your computer and use it in GitHub Desktop.
Save nigelheap/1013819 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