-
-
Save Graywolf9/2983c1ca5c3521e77b78976cefaded25 to your computer and use it in GitHub Desktop.
Generate list of pages in Drupal
This file contains 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 | |
/** | |
* @file gets "path, title" csv format of entries from node, menu_links, menu_router | |
* | |
* run from within drupal project root: drush scr generate_list.php | |
*/ | |
// Bootstrap Drupal | |
define('DRUPAL_ROOT', getcwd()); | |
require_once DRUPAL_ROOT . '/includes/bootstrap.inc'; | |
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); | |
$list = array(array("path", "title")); | |
$result = db_query('select path, title from menu_router')->fetchAll(); | |
$router_items = array(); | |
foreach ($result as $obj) { | |
$router_items[] = get_object_vars($obj); | |
} | |
$list = array_merge($list, $router_items); | |
$result = db_query('select link_path, link_title from menu_links')->fetchAll(); | |
$items = array(); | |
foreach ($result as $obj) { | |
$items[] = get_object_vars($obj); | |
} | |
$list = array_merge($list, $items); | |
// find nodes | |
$res = db_query('select nid from node')->fetchAll(); | |
$nodes = array(); | |
foreach ($res as $obj) { | |
$node = node_load($obj->nid); | |
$arr = array(drupal_get_path_alias('node/' . $node->nid), $node->title); | |
$nodes[] = $arr; | |
} | |
$list = array_merge($list, $nodes); | |
// print csv | |
foreach ($list as $row) { | |
print_r(implode(',',$row)); | |
print "\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment