1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-11 17:14:42 +02:00

The {CHAPTER_MENUS} shortcode now accepts the 'template' parameter. Additional Custom Menu shortcodes/aliases added:

{CMENU_TAB_ACTIVE} {CMENU_BUTTON_TEXT} {CMENU_BUTTON_URL}
This commit is contained in:
Cameron
2017-10-26 11:21:18 -07:00
parent 933691b93f
commit 1b3168dcbc
2 changed files with 82 additions and 19 deletions

View File

@@ -344,23 +344,43 @@ class cpage_shortcodes extends e_shortcode
{
$tp = e107::getParser();
if($parm == 'url')
{
$img = ($tp->isVideo($this->var['menu_image'])) ? $tp->toVideo($this->var['menu_image'], array('thumb'=>'src')) : $tp->thumbUrl($this->var['menu_image']);
return $img;
}
if($video = $tp->toVideo($this->var['menu_image']))
{
return $video;
}
if($parm == 'url')
{
$img = $tp->thumbUrl($this->var['menu_image']);
return $img;
}
return $tp->toImage($this->var['menu_image'], $parm);
//return "<img class='".$class."' src='".$img."' alt='' ".$dimensions." />";
}
function sc_cmenu_tab_active($parm=null)
{
if(!empty($this->var['cmenu_tab_active']))
{
return 'active';
}
return null;
}
function sc_cmenu_button_text($parm=null)
{
return (empty($this->var['menu_button_text'])) ? LAN_READ_MORE : $this->var['menu_button_text'];
}
function sc_cmenu_button_url($parm=null)
{
return $this->sc_cmenuurl($parm);
}
function sc_cmenuicon($parm='')
{
if($parm === 'css')

View File

@@ -133,19 +133,33 @@ class page_shortcodes extends e_shortcode
* Render All visible Menus from a specific chapter.
* @param null $parm
* @example {CHAPTER_MENUS: name=chapter-sef-url}
* @example {CHAPTER_MENUS: name=chapter-sef-url&template=xxxxx}
* @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 p.menu_class IN (" . USERCLASS_LIST . ") AND ch.chapter_sef = '" . $tp->filter($parm['name'],'str') . "' ORDER BY p.page_order ASC ";
$text = '';
$start = '';
if(!$pageArray = e107::getDb()->retrieve($query, true))
$sef = $tp->filter($parm['name'],'str');
$registry = 'e_shortcode/sc_chapter_menus/'.$sef;
if(!$pageArray = e107::getRegistry($registry))
{
e107::getDebug()->log('{CHAPTER_MENUS: name='.$parm['name'].'} failed.<br />Query: '.$query);
return null;
$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 p.menu_class IN (" . USERCLASS_LIST . ") AND ch.chapter_sef = '" . $sef . "' ORDER BY p.page_order ASC ";
e107::getDebug()->log("Loading page Chapters");
if(!$pageArray = e107::getDb()->retrieve($query, true))
{
e107::getDebug()->log('{CHAPTER_MENUS: name='.$parm['name'].'} failed.<br />Query: '.$query);
return null;
}
e107::setRegistry($registry, $pageArray);
}
$template = e107::getCoreTemplate('menu',null,true,true);
@@ -154,19 +168,48 @@ class page_shortcodes extends e_shortcode
$sc->setVars($pageArray[0]);
$tpl = varset($pageArray[0]['menu_template'],'default'); // use start template from first row.
$start = $tp->parseTemplate($template[$tpl]['start'],true,$sc);
foreach($pageArray as $row)
if(!empty($parm['template']))
{
$tpl = varset($row['menu_template'],'default');
$sc->setVars($row);
$text .= $tp->parseTemplate($template[$tpl]['body'],true,$sc);
$tpl = $parm['template'];
$start .= "<!-- CHAPTER_MENUS Start Template: ". $tpl." -->";
if(empty($template[$tpl]))
{
e107::getDebug()->log('{CHAPTER_MENUS: '.http_build_query($parm).'} has an empty template.');
}
}
$active = varset($parm['active'],1);
$start .= $tp->parseTemplate($template[$tpl]['start'],true,$sc);
$c=1;
foreach($pageArray as $row)
{
$row['cmenu_tab_active'] = ($c === $active) ? true : false;
if(empty($parm['template']))
{
$tpl = varset($row['menu_template'],'default');
}
$sc->setVars($row);
$text .= $tp->parseTemplate($template[$tpl]['body'],true,$sc);
$c++;
}
$end = $tp->parseTemplate($template[$tpl]['end'],true,$sc);
$end .= "<!-- ".http_build_query($parm)." -->";
if(!empty($parm['template']))
{
$end .= "<!-- CHAPTER_MENUS end template: ". $parm['template']." -->";
}
if(!empty($text))
{
return $start . $text . $end;