diff --git a/e107_core/shortcodes/batch/page_shortcodes.php b/e107_core/shortcodes/batch/page_shortcodes.php
index 7ab5e2a51..6c2ff75e3 100644
--- a/e107_core/shortcodes/batch/page_shortcodes.php
+++ b/e107_core/shortcodes/batch/page_shortcodes.php
@@ -440,6 +440,38 @@ class cpage_shortcodes extends e_shortcode
return ''.$text.'';
}
+
+
+ function sc_chapter_breadcrumb()
+ {
+ $tp = e107::getParser();
+
+ $breadcrumb = array();
+
+ $row = $this->getChapter();
+ $brow = $this->getBook($row['chapter_parent']);
+
+ if(empty($brow['chapter_sef']))
+ {
+ return;
+ }
+
+ $row['book_sef'] = vartrue($brow['chapter_sef'],"no-sef-found"); //$this->getBook();
+
+
+ $breadcrumb[] = array('text'=> $brow['chapter_name'], 'url'=> e107::getUrl()->create('page/book/index', $brow,'allow=chapter_id,chapter_sef,book_sef,page_sef'));
+ $breadcrumb[] = array('text'=> $row['chapter_name'], 'url'=> e107::getUrl()->create('page/chapter/index', $row,'allow=chapter_id,chapter_sef,book_sef'));
+ // $breadcrumb[] = array('text'=> $this->var['page_title'], 'url'=> null);
+
+
+ return e107::getForm()->breadcrumb($breadcrumb);
+
+
+ }
+
+
+
+
/**
* @example {CPAGERELATED: types=news}
diff --git a/e107_core/templates/chapter_template.php b/e107_core/templates/chapter_template.php
index d4db9130b..d46cc7893 100644
--- a/e107_core/templates/chapter_template.php
+++ b/e107_core/templates/chapter_template.php
@@ -106,15 +106,18 @@ $CHAPTER_TEMPLATE['nav']['listPages'] = $CHAPTER_TEMPLATE['nav']['listChapters']
$CHAPTER_TEMPLATE['nav']['showPage'] = $CHAPTER_TEMPLATE['nav']['listChapters'];
-// Used by e107_plugins/page/chapter_menu.php
+// Used by e107_plugins/page/chapter_menu.php & /page.php?bk=x
+$CHAPTER_TEMPLATE['panel']['listChapters']['caption'] = "{BOOK_NAME}";
$CHAPTER_TEMPLATE['panel']['listChapters']['start'] = "
";
-$CHAPTER_TEMPLATE['panel']['listPages']['item'] = "{SETSTYLE=none}
";
+$CHAPTER_TEMPLATE['panel']['listPages']['start'] = "{CHAPTER_BREADCRUMB}
";
+$CHAPTER_TEMPLATE['panel']['listPages']['item'] = "
";
$CHAPTER_TEMPLATE['panel']['listPages']['end'] = "
";
?>
\ No newline at end of file
diff --git a/e107_core/templates/page_template.php b/e107_core/templates/page_template.php
index f3381ac52..aa911e58b 100644
--- a/e107_core/templates/page_template.php
+++ b/e107_core/templates/page_template.php
@@ -35,7 +35,7 @@ $sc_style['CPAGENAV|default']['post'] = '
';
';
// always used - it's inside the {PAGE} sc from 'page' template
- $PAGE_TEMPLATE['default']['start'] = '';
+ $PAGE_TEMPLATE['default']['start'] = '
{CHAPTER_BREADCRUMB}';
// page body
$PAGE_TEMPLATE['default']['body'] = '
diff --git a/e107_plugins/page/chapter_menu.php b/e107_plugins/page/chapter_menu.php
index 37b63e70f..425243f1a 100644
--- a/e107_plugins/page/chapter_menu.php
+++ b/e107_plugins/page/chapter_menu.php
@@ -29,7 +29,7 @@ $data = $sql->retrieve("SELECT * FROM #page_chapters WHERE chapter_visibility IN
$sc = e107::getScBatch('page', null, 'cpage');
-echo $template['listChapters']['start'];
+$body = $template['listChapters']['start'];
foreach($data as $row)
{
@@ -37,11 +37,15 @@ foreach($data as $row)
$sc->setChapter($row['chapter_id']);
$title = $tp->toHtml($row['chapter_name'],false,'TITLE'); // Used when tablerender style includes the caption.
- $body = $tp->parseTemplate($template['listChapters']['item'], true, $sc);
+ $body .= $tp->parseTemplate($template['listChapters']['item'], true, $sc);
- $ns->tablerender($title, $body, 'chapter-menu'); // check for $mode == 'page-menu' in tablestyle() if you need a simple 'echo' without rendering styles.
+ // check for $mode == 'page-menu' in tablestyle() if you need a simple 'echo' without rendering styles.
}
-echo $template['listChapters']['end'];
+$body .= $template['listChapters']['end'];
+
+$caption = $tp->parseTemplate($template['listChapters']['caption'], true, $sc);
+
+$ns->tablerender($caption, $body, 'chapter-menu');
?>
\ No newline at end of file
diff --git a/page.php b/page.php
index 4cc894fa6..0336148b2 100644
--- a/page.php
+++ b/page.php
@@ -40,8 +40,8 @@ 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-chapter-list'); // TODO FIXME Caption eg. "book title"
+ $data = $e107CorePage->listChapters($_GET['bk']);
+ $ns->tablerender($data['caption'], $data['text'], 'cpage-chapter-list'); // TODO FIXME Caption eg. "book title"
require_once(FOOTERF);
exit;
}
@@ -143,7 +143,7 @@ class pageClass
$this->debug .= "pageSelected ".$this->pageSelected."
";
}
- $books = e107::getDb()->retrieve("SELECT chapter_id,chapter_sef FROM #page_chapters ORDER BY chapter_id ASC" , true);
+ $books = e107::getDb()->retrieve("SELECT chapter_id,chapter_sef,chapter_name FROM #page_chapters ORDER BY chapter_id ASC" , true);
foreach($books as $row)
{
@@ -229,6 +229,8 @@ class pageClass
$text = $template['start'];
+
+
while($row = $sql->fetch())
{
@@ -236,12 +238,14 @@ class pageClass
$sef['book_sef'] = $this->getSef($row['chapter_id']);
$sef['page_sef'] = $this->getSef($row['chapter_id']);
+ $listChapters = $this->listChapters(intval($row['chapter_id']), $row['chapter_sef']);
+
$var = array(
'BOOK_NAME' => $tp->toHtml($row['chapter_name']),
'BOOK_ANCHOR' => $frm->name2id($row['chapter_name']),
'BOOK_ICON' => $this->chapterIcon($row['chapter_icon']),
'BOOK_DESCRIPTION' => $tp->toHtml($row['chapter_meta_description'],true,'BODY'),
- 'CHAPTERS' => $this->listChapters(intval($row['chapter_id']), $row['chapter_sef']),
+ 'CHAPTERS' => $listChapters['text'],
'BOOK_URL' => e107::getUrl()->create('page/book/index', $sef,'allow=chapter_id,chapter_sef,book_sef,page_sef') // e_BASE."page.php?bk=".intval($row['chapter_id']) // FIXME SEF-URL
);
@@ -285,24 +289,41 @@ class pageClass
$tp = e107::getParser();
$frm = e107::getForm();
- // retrieve the template to use for this book
- if(!$layout = $sql->retrieve('page_chapters','chapter_template','chapter_id = '.intval($book).' AND chapter_visibility IN ('.USERCLASS_LIST.') LIMIT 1'))
+ // retrieve book information.
+ if(!$brow = $sql->retrieve('page_chapters','chapter_name,chapter_template','chapter_id = '.intval($book).' AND chapter_visibility IN ('.USERCLASS_LIST.') LIMIT 1'))
{
$layout = 'default';
}
+ else
+ {
+ $layout = $brow['chapter_template'];
+ }
if($this->displayAllMode === true)
{
$layout = e107::getPref('listBooksTemplate');
}
- $error = array('listChapters' => array('start'=>"Chapter template not found: ".$layout));
+
$tml = e107::getCoreTemplate('chapter','', true, true); // always merge
+
+ $error = array('listChapters' => array('start'=>"Chapter template not found: ".$layout));
$tmpl = varset($tml[$layout],$error );
$template = $tmpl['listChapters'];
+ $bvar = array(
+ 'BOOK_NAME' => $tp->toHtml($brow['chapter_name']),
+ 'BOOK_ANCHOR' => $frm->name2id($brow['chapter_name']),
+ 'BOOK_ICON' => $this->chapterIcon($brow['chapter_icon']),
+ 'BOOK_DESCRIPTION' => $tp->toHtml($brow['chapter_meta_description'],true,'BODY'),
+ );
+
+ $caption = $tp->simpleParse($template['caption'],$bvar);
+
+
+
if($sql->select("page_chapters", "*", "chapter_parent = ".intval($book)." AND chapter_visibility IN (".USERCLASS_LIST.") ORDER BY chapter_order ASC "))
{
$text .= $template['start'];
@@ -341,8 +362,8 @@ class pageClass
{
$text = e107::getMessage()->addInfo("There are no chapters in this book")->render();
}
-
- return $text;
+
+ return array('caption'=>$caption, 'text'=>$text);
}
@@ -389,16 +410,34 @@ class pageClass
$layout = vartrue($row['chapter_template'],'default');
}
+ $bookId = $row['chapter_parent'];
$bookSef = $this->getSef($row['chapter_parent']);
+ $bookTitle = $this->getName($row['chapter_parent']);
+
+ $urlData = array(
+ 'chapter_id' => $row['chapter_id'],
+ 'chapter_name' => $tp->toHtml($row['chapter_name']),
+ 'chapter_sef' => $bookSef,
+ 'book_sef' => $bookSef,
+ 'page_sef' => ''
+ );
+
+
+ //print_a($this->chapterData);
$tml = e107::getCoreTemplate('chapter','', true, true); // always merge
$tmpl = varset($tml[$layout]);
+
+ $bread = array(
+ 0 => array('text' => $tp->toHtml($bookTitle), 'url'=> e107::getUrl()->create('page/book/index', $urlData,'allow=chapter_id,chapter_sef,book_sef,page_sef'))
+ );
$var = array(
'CHAPTER_NAME' => $tp->toHtml($row['chapter_name']),
'CHAPTER_ANCHOR' => $frm->name2id($row['chapter_name']),
'CHAPTER_ICON' => $this->chapterIcon($row['chapter_icon']),
- 'CHAPTER_DESCRIPTION' => $tp->toHtml($row['chapter_meta_description'], true,'BODY')
+ 'CHAPTER_DESCRIPTION' => $tp->toHtml($row['chapter_meta_description'], true,'BODY'),
+ 'CHAPTER_BREADCRUMB' => $frm->breadcrumb($bread)
);