1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-31 20:00:37 +02:00

Fixes #594 - cpage_shortcodes notice. Also resolves long-standing conflict between page.php and other scripts using the same cpage shortcodes. These changes will require much testing. Added new chapter menu. (useful for menus on the Home page that link to chapters)

This commit is contained in:
Cameron
2014-06-13 03:39:41 -07:00
parent c3f986b77c
commit 8bb72d1d4c
6 changed files with 231 additions and 105 deletions

View File

@@ -0,0 +1,47 @@
<?php
/**
* e107 website system
*
* Copyright (C) 2008-2013 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* Purpose: Display a Menu item (panel) for each 'chapter' of a specific book. ie. the chapter-equivalent of {CMENU} .
* @example in theme.php: {MENU: path=page/chapter&book=1} to render all chapters in book 1.
*/
if (!defined('e107_INIT')) { exit; }
$sql = e107::getDb();
$ns = e107::getRender();
$tp = e107::getParser();
$parm = eHelper::scParams($parm);
$template = e107::getCoreTemplate('chapter','panel');
$insert = (vartrue($parm['book'])) ? "AND chapter_parent = ".intval($parm['book']) : '';
//TODO Limits and cache etc.
$data = $sql->retrieve("SELECT * FROM #page_chapters WHERE chapter_visibility IN (".USERCLASS_LIST.") AND chapter_template = 'panel' ".$insert. " LIMIT 24", true);
$sc = e107::getScBatch('page', null, 'cpage');
echo $template['listChapters']['start'];
foreach($data as $row)
{
$sc->setVars($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);
$ns->tablerender($title, $body, 'chapter-menu'); // check for $mode == 'page-menu' in tablestyle() if you need a simple 'echo' without rendering styles.
}
echo $template['listChapters']['end'];
?>