1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-17 12:48:24 +01:00

Smarter page navigation menu

This commit is contained in:
SecretR 2013-02-14 13:06:16 +02:00
parent b9a452e793
commit cd2fbaa3d6
3 changed files with 65 additions and 7 deletions

View File

@ -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 "<h3>Compiled</h3>";
$outArray = array();
$ret = e107::getNav()->compile($arr, $outArray, $parent);

View File

@ -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');

View File

@ -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.