mirror of
https://github.com/e107inc/e107.git
synced 2025-07-30 11:20:25 +02:00
Page/Menus : New Shortcode {CHAPTER_MENUS: id=chapter-sef-url} Render menus from a given chapter.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
@@ -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.<br />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;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user