From 01801d6b9412d7ea8df37ca684d6ee72a806040e Mon Sep 17 00:00:00 2001 From: Cameron Date: Wed, 25 Jan 2017 13:08:53 -0800 Subject: [PATCH] Page/Menus : New Shortcode {CHAPTER_MENUS: id=chapter-sef-url} Render menus from a given chapter. --- e107_handlers/e_customfields_class.php | 5 +++- e107_plugins/page/e_shortcode.php | 40 +++++++++++++++++++++++++- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/e107_handlers/e_customfields_class.php b/e107_handlers/e_customfields_class.php index e428c35ed..b6368fda9 100644 --- a/e107_handlers/e_customfields_class.php +++ b/e107_handlers/e_customfields_class.php @@ -55,7 +55,8 @@ $this->_config = e107::unserialize($data); - e107::getDebug()->log($this->_config); + // e107::getDebug()->log($this->_config); + return $this; } @@ -70,6 +71,8 @@ { $this->_data = e107::unserialize($data); + // e107::getDebug()->log($this->_data); + return $this; } diff --git a/e107_plugins/page/e_shortcode.php b/e107_plugins/page/e_shortcode.php index 1ba0c8cbb..f8ca91dc8 100644 --- a/e107_plugins/page/e_shortcode.php +++ b/e107_plugins/page/e_shortcode.php @@ -16,7 +16,8 @@ class page_shortcodes extends e_shortcode function __construct() { - + + $this->request = e107::getRegistry('core/page/request'); $action = varset($this->request['action']); @@ -126,4 +127,41 @@ class page_shortcodes extends e_shortcode { return e107::getMenu()->renderMenu($parm, false, false, true); } + + + /** + * Render All visible Menus from a specific chapter. + * @param null $parm + * @example {CHAPTER_MENUS: id=chapter-sef-url} + * @return string + */ + function sc_chapter_menus($parm=null) + { + $tp = e107::getParser(); + $query = "SELECT * FROM #page AS p LEFT JOIN #page_chapters as ch ON p.page_chapter=ch.chapter_id WHERE ch.chapter_visibility IN (" . USERCLASS_LIST . ") AND ch.chapter_sef = '" . $tp->filter($parm['id'],'str') . "' ORDER BY p.page_order DESC "; + + $text = ''; + + if(!$pageArray = e107::getDb()->retrieve($query, true)) + { + e107::getDebug()->log('{CHAPTER_MENUS: id='.$parm['id'].'} failed.
Query: '.$query); + return null; + } + + $template = e107::getCoreTemplate('menu',null,true,true); + + $sc = e107::getScBatch('page', null, 'cpage'); + + foreach($pageArray as $row) + { + $tpl = varset($row['menu_template'],'default'); + $sc->setVars($row); + $text .= $tp->parseTemplate($template[$tpl]['start'],true,$sc); + $text .= $tp->parseTemplate($template[$tpl]['body'],true,$sc); + $text .= $tp->parseTemplate($template[$tpl]['end'],true,$sc); + } + + return $text; + } + }