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

Custom Page fixes and page breadcrumbs

This commit is contained in:
Cameron 2014-06-13 19:00:51 -07:00
parent 791608f0d7
commit 31e29bb892
5 changed files with 97 additions and 19 deletions

View File

@ -440,6 +440,38 @@ class cpage_shortcodes extends e_shortcode
return '<a class="cpage btn btn-primary btn-chapter'.$inc.'" href="'.$url.'">'.$text.'</a>'; return '<a class="cpage btn btn-primary btn-chapter'.$inc.'" href="'.$url.'">'.$text.'</a>';
} }
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} * @example {CPAGERELATED: types=news}

View File

@ -106,15 +106,18 @@ $CHAPTER_TEMPLATE['nav']['listPages'] = $CHAPTER_TEMPLATE['nav']['listChapters']
$CHAPTER_TEMPLATE['nav']['showPage'] = $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'] = "<div class='chapter-panel-list'>"; $CHAPTER_TEMPLATE['panel']['listChapters']['start'] = "<div class='chapter-panel-list'>";
$CHAPTER_TEMPLATE['panel']['listChapters']['item'] = "<h1><a href='{CHAPTER_URL}' >{CHAPTER_ICON}</a></h1><br /><p>{CHAPTER_DESCRIPTION}</p><p>{CHAPTER_BUTTON}</p>"; $CHAPTER_TEMPLATE['panel']['listChapters']['item'] = "<div class='col-xs-12 col-md-4 text-center'>
<h2>{CHAPTER_NAME}</h2>
<h1><a href='{CHAPTER_URL}' >{CHAPTER_ICON}</a></h1><p>{CHAPTER_DESCRIPTION}</p><p>{CHAPTER_BUTTON}</p></div>";
$CHAPTER_TEMPLATE['panel']['listChapters']['end'] = "</div>"; $CHAPTER_TEMPLATE['panel']['listChapters']['end'] = "</div>";
$CHAPTER_TEMPLATE['panel']['listPages']['caption'] = "{CHAPTER_NAME}"; $CHAPTER_TEMPLATE['panel']['listPages']['caption'] = "{CHAPTER_NAME}";
$CHAPTER_TEMPLATE['panel']['listPages']['start'] = "<div class='chapter-pages-list'>"; $CHAPTER_TEMPLATE['panel']['listPages']['start'] = "{CHAPTER_BREADCRUMB}<div class='chapter-pages-list'>";
$CHAPTER_TEMPLATE['panel']['listPages']['item'] = "{SETSTYLE=none}<div class='section'><div class='row'>{CPAGEMENU}</div></div>"; $CHAPTER_TEMPLATE['panel']['listPages']['item'] = "<div class='section'><div class='row'>{CPAGEMENU}</div></div>";
$CHAPTER_TEMPLATE['panel']['listPages']['end'] = "</div>"; $CHAPTER_TEMPLATE['panel']['listPages']['end'] = "</div>";
?> ?>

View File

@ -35,7 +35,7 @@ $sc_style['CPAGENAV|default']['post'] = '</div>';
'; ';
// always used - it's inside the {PAGE} sc from 'page' template // always used - it's inside the {PAGE} sc from 'page' template
$PAGE_TEMPLATE['default']['start'] = '<div id="{CPAGESEF}" class="cpage_body cpage-body">'; $PAGE_TEMPLATE['default']['start'] = '<div id="{CPAGESEF}" class="cpage_body cpage-body">{CHAPTER_BREADCRUMB}';
// page body // page body
$PAGE_TEMPLATE['default']['body'] = ' $PAGE_TEMPLATE['default']['body'] = '

View File

@ -29,7 +29,7 @@ $data = $sql->retrieve("SELECT * FROM #page_chapters WHERE chapter_visibility IN
$sc = e107::getScBatch('page', null, 'cpage'); $sc = e107::getScBatch('page', null, 'cpage');
echo $template['listChapters']['start']; $body = $template['listChapters']['start'];
foreach($data as $row) foreach($data as $row)
{ {
@ -37,11 +37,15 @@ foreach($data as $row)
$sc->setChapter($row['chapter_id']); $sc->setChapter($row['chapter_id']);
$title = $tp->toHtml($row['chapter_name'],false,'TITLE'); // Used when tablerender style includes the caption. $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');
?> ?>

View File

@ -40,8 +40,8 @@ elseif(vartrue($_GET['bk'])) // List Chapters within a specific Book
$e107CorePage->setRequest('listChapters'); $e107CorePage->setRequest('listChapters');
require_once(HEADERF); require_once(HEADERF);
$text = $e107CorePage->listChapters($_GET['bk']); $data = $e107CorePage->listChapters($_GET['bk']);
$ns->tablerender('', $text, 'cpage-chapter-list'); // TODO FIXME Caption eg. "book title" $ns->tablerender($data['caption'], $data['text'], 'cpage-chapter-list'); // TODO FIXME Caption eg. "book title"
require_once(FOOTERF); require_once(FOOTERF);
exit; exit;
} }
@ -143,7 +143,7 @@ class pageClass
$this->debug .= "<b>pageSelected</b> ".$this->pageSelected." <br />"; $this->debug .= "<b>pageSelected</b> ".$this->pageSelected." <br />";
} }
$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) foreach($books as $row)
{ {
@ -229,6 +229,8 @@ class pageClass
$text = $template['start']; $text = $template['start'];
while($row = $sql->fetch()) while($row = $sql->fetch())
{ {
@ -236,12 +238,14 @@ class pageClass
$sef['book_sef'] = $this->getSef($row['chapter_id']); $sef['book_sef'] = $this->getSef($row['chapter_id']);
$sef['page_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( $var = array(
'BOOK_NAME' => $tp->toHtml($row['chapter_name']), 'BOOK_NAME' => $tp->toHtml($row['chapter_name']),
'BOOK_ANCHOR' => $frm->name2id($row['chapter_name']), 'BOOK_ANCHOR' => $frm->name2id($row['chapter_name']),
'BOOK_ICON' => $this->chapterIcon($row['chapter_icon']), 'BOOK_ICON' => $this->chapterIcon($row['chapter_icon']),
'BOOK_DESCRIPTION' => $tp->toHtml($row['chapter_meta_description'],true,'BODY'), '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 '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(); $tp = e107::getParser();
$frm = e107::getForm(); $frm = e107::getForm();
// retrieve the template to use for this book // retrieve book information.
if(!$layout = $sql->retrieve('page_chapters','chapter_template','chapter_id = '.intval($book).' AND chapter_visibility IN ('.USERCLASS_LIST.') LIMIT 1')) if(!$brow = $sql->retrieve('page_chapters','chapter_name,chapter_template','chapter_id = '.intval($book).' AND chapter_visibility IN ('.USERCLASS_LIST.') LIMIT 1'))
{ {
$layout = 'default'; $layout = 'default';
} }
else
{
$layout = $brow['chapter_template'];
}
if($this->displayAllMode === true) if($this->displayAllMode === true)
{ {
$layout = e107::getPref('listBooksTemplate'); $layout = e107::getPref('listBooksTemplate');
} }
$error = array('listChapters' => array('start'=>"Chapter template not found: ".$layout));
$tml = e107::getCoreTemplate('chapter','', true, true); // always merge $tml = e107::getCoreTemplate('chapter','', true, true); // always merge
$error = array('listChapters' => array('start'=>"Chapter template not found: ".$layout));
$tmpl = varset($tml[$layout],$error ); $tmpl = varset($tml[$layout],$error );
$template = $tmpl['listChapters']; $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 ")) if($sql->select("page_chapters", "*", "chapter_parent = ".intval($book)." AND chapter_visibility IN (".USERCLASS_LIST.") ORDER BY chapter_order ASC "))
{ {
$text .= $template['start']; $text .= $template['start'];
@ -341,8 +362,8 @@ class pageClass
{ {
$text = e107::getMessage()->addInfo("There are no chapters in this book")->render(); $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'); $layout = vartrue($row['chapter_template'],'default');
} }
$bookId = $row['chapter_parent'];
$bookSef = $this->getSef($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 $tml = e107::getCoreTemplate('chapter','', true, true); // always merge
$tmpl = varset($tml[$layout]); $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( $var = array(
'CHAPTER_NAME' => $tp->toHtml($row['chapter_name']), 'CHAPTER_NAME' => $tp->toHtml($row['chapter_name']),
'CHAPTER_ANCHOR' => $frm->name2id($row['chapter_name']), 'CHAPTER_ANCHOR' => $frm->name2id($row['chapter_name']),
'CHAPTER_ICON' => $this->chapterIcon($row['chapter_icon']), '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)
); );