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

51 lines
1.5 KiB
PHP
Raw Normal View History

<?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');
2014-06-13 19:00:51 -07:00
$body = $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.
2014-06-13 19:00:51 -07:00
$body .= $tp->parseTemplate($template['listChapters']['item'], true, $sc);
2014-06-13 19:00:51 -07:00
// check for $mode == 'page-menu' in tablestyle() if you need a simple 'echo' without rendering styles.
}
2014-06-13 19:00:51 -07:00
$body .= $template['listChapters']['end'];
$caption = $tp->parseTemplate($template['listChapters']['caption'], true, $sc);
$ns->tablerender($caption, $body, 'chapter-menu');