diff --git a/e107_plugins/page/e_sitelink.php b/e107_plugins/page/e_sitelink.php index 1533c3949..b21c4185e 100644 --- a/e107_plugins/page/e_sitelink.php +++ b/e107_plugins/page/e_sitelink.php @@ -30,6 +30,7 @@ class page_sitelinks // include plugin-folder in the name. function pageNav($parm='') { + $options = array(); if(vartrue($parm)) { parse_str($parm,$options); @@ -45,11 +46,11 @@ class page_sitelinks // include plugin-folder in the name. // $query .= vartrue($options['limit']) ? " LIMIT ".intval($options['limit']) : ""; $data = $sql->retrieve($query, true); - + $_pdata = array(); foreach($data as $row) { $pid = $row['page_chapter']; - $sublinks[$pid][] = array( + $sublinks[$pid][] = $_pdata[] = array( 'link_id' => $row['page_id'], 'link_name' => $row['page_title'], 'link_url' => e107::getUrl()->create('page/view', $row, array('allow' => 'page_sef,page_title,page_id')), @@ -69,7 +70,9 @@ class page_sitelinks // include plugin-folder in the name. if(vartrue($options['chapter'])) { - $filter = "chapter_id > ".intval($options['chapter']); + //$filter = "chapter_id > ".intval($options['chapter']); + $outArray = array(); + return e107::getNav()->compile($_pdata, $outArray, $options['chapter']); } if(vartrue($options['book'])) @@ -107,7 +110,6 @@ class page_sitelinks // include plugin-folder in the name. // print_a($arr); - // echo "

Compiled

"; $outArray = array(); $ret = e107::getNav()->compile($arr, $outArray, $parent); diff --git a/e107_plugins/page/page_navigation_menu.php b/e107_plugins/page/page_navigation_menu.php index 84f8ab779..12a0f9210 100644 --- a/e107_plugins/page/page_navigation_menu.php +++ b/e107_plugins/page/page_navigation_menu.php @@ -12,7 +12,32 @@ if (!defined('e107_INIT')) { exit; } $template = e107::getCoreTemplate('page','nav'); -$text = e107::getParser()->parseTemplate("{PAGE_NAVIGATION}", true); +// auto mode - detect the current location +if(empty($parm)) +{ + $request = e107::getRegistry('core/pages/request'); + $parm = array(); + if($request && is_array($request)) + { + switch ($request['action']) + { + case 'listChapters': + $parm['book'] = $request['id']; + break; + + case 'listPages': + $parm['chapter'] = $request['id']; + break; + + case 'showPage': + $parm['page'] = $request['id']; + break; + } + } + if($parm) $parm = http_build_query($parm); +} + +$text = e107::getParser()->parseTemplate("{PAGE_NAVIGATION={$parm}}", true); e107::getRender()->tablerender($template['caption'], $text, 'page-navigation-menu'); diff --git a/page.php b/page.php index bce7cf8b7..0e2ead5ff 100644 --- a/page.php +++ b/page.php @@ -17,9 +17,11 @@ e107::coreLan('page'); $e107CorePage = new pageClass(false); - +// Important - save request BEFORE any output (header footer) - used in navigation menu if(!e_QUERY) { + $e107CorePage->setRequest('listBooks'); + require_once(HEADERF); // $tmp = $e107CorePage->listPages(); $tmp = $e107CorePage->listBooks(); @@ -34,6 +36,8 @@ if(!e_QUERY) } elseif(vartrue($_GET['bk'])) // List Chapters within a specific Book { + $e107CorePage->setRequest('listChapters'); + require_once(HEADERF); $text = $e107CorePage->listChapters($_GET['bk']); $ns->tablerender('', $text, 'cpage'); // TODO FIXME Caption eg. "book title" @@ -42,6 +46,8 @@ elseif(vartrue($_GET['bk'])) // List Chapters within a specific Book } elseif(vartrue($_GET['ch'])) // List Pages within a specific Chapter { + $e107CorePage->setRequest('listPages'); + require_once(HEADERF); $text = $e107CorePage->listPages($_GET['ch']); @@ -51,7 +57,7 @@ elseif(vartrue($_GET['ch'])) // List Pages within a specific Chapter } else { - + $e107CorePage->setRequest('showPage'); $e107CorePage->processViewPage(); require_once(HEADERF); @@ -132,6 +138,31 @@ class pageClass } + // XXX temporary solution - upcoming page rewrite + public function setRequest($request) + { + switch ($request) + { + case 'listChapters': + $id = intval($_GET['bk']); + break; + + case 'listPages': + $id = intval($_GET['ch']); + break; + + case 'showPage': + $id = $this->pageID; + break; + + case 'listBooks': + default: + $id = 0; + break; + } + e107::setRegistry('core/pages/request', array('action' => $request, 'id' => $id)); + } + //XXX - May be better to compile into assoc 'tree' array first. ie. books/chapters/pages.