2009-08-13, 09:35:13
badcat - yes should work with pretty vs URL. Slug name is passed to the page not the menu text
g.net - sample function here. assuming "|" is the delimeter.
I'm just exploding the menu text string and outputting $peices[1] & pieces[2] instead, style as you need.
rest of the function is identical to original.
Mike
g.net - sample function here. assuming "|" is the delimeter.
Code:
function get_mynavigation($currentpage) {
global $PRETTYURLS;
global $SITEURL;
$menu = '';
$path = "data/pages";
$dir_handle = @opendir($path) or die("Unable to open $path");
$filenames = array();
while ($filename = readdir($dir_handle)) {
$filenames[] = $filename;
}
$count="0";
$pagesArray = array();
if (count($filenames) != 0) {
foreach ($filenames as $file) {
if ($file == "." || $file == ".." || is_dir("data/pages/".$file) || $file == ".htaccess" ) {
// not a page data file
} else {
$thisfile = @file_get_contents('data/pages/'.$file);
$data = simplexml_load_string($thisfile);
if ($data->private != 'Y') {
$pagesArray[$count]['menuStatus'] = $data->menuStatus;
$pagesArray[$count]['menuOrder'] = $data->menuOrder;
$pagesArray[$count]['menu'] = strtoupper($data->menu);
$pagesArray[$count]['url'] = $data->url;
$pagesArray[$count]['title'] = $data->title;
$pagesArray[$count]['parent'] = $data->parent;
$count++;
}
}
}
}
$pagesSorted = subval_sort($pagesArray,'menuOrder');
if (count($pagesSorted) != 0) {
foreach ($pagesSorted as $page) {
$sel = ''; $classes = '';
$url_nav = $page['url'];
if ($page['menuStatus'] == 'Y') {
if ("$currentpage" == "$url_nav") { $classes = "current ". $url_nav; } else { $classes = $url_nav; }
if ($page['menu'] == '') { $page['menu'] = $page['title']; }
if ($page['title'] == '') { $page['title'] = $page['menu']; }
if ($PRETTYURLS == '1') {
if ($page['parent'] != '') {$page['parent'] = $page['parent']."/"; }
// parse menu text for | and split output
$pieces = explode("|", $page['menu']);
if ($url_nav == 'index' ) { $url_nav = ''; }
$menu .= '<li><a class="nav" href="'. $SITEURL . @$page['parent'] . $url_nav .'" title="'.stripslashes(strip_tags(html_entity_decode($page['title']))).'">'.$pieces[0].'<br/>'.$pieces[1].'</a></li>';
} else {
$menu .= '<li><a class="nav" href="'. $SITEURL .'index.php?id='.$url_nav.'" title="'.stripslashes(strip_tags(html_entity_decode($page['title']))).'">'..$pieces[0].'<br/>'.$pieces[1].'</a></li>';
}
}
}
echo $menu;
echo "<div class=\"clearer\"> </div>";
}
closedir($dir_handle);
}
I'm just exploding the menu text string and outputting $peices[1] & pieces[2] instead, style as you need.
rest of the function is identical to original.
Mike