diff --git a/e107_core/templates/navigation_template.php b/e107_core/templates/navigation_template.php
index d380686a2..9a7309eda 100644
--- a/e107_core/templates/navigation_template.php
+++ b/e107_core/templates/navigation_template.php
@@ -70,6 +70,13 @@ $NAVIGATION_TEMPLATE['main']['submenu_loweritem'] = '
';
+$NAVIGATION_TEMPLATE['main']['submenu_loweritem_active'] = '
+
+';
+
$NAVIGATION_TEMPLATE['main']['submenu_item_active'] = '
{LINK_IMAGE}{LINK_NAME}
diff --git a/e107_core/templates/page_template.php b/e107_core/templates/page_template.php
index c97064388..e58ce55a9 100644
--- a/e107_core/templates/page_template.php
+++ b/e107_core/templates/page_template.php
@@ -143,16 +143,6 @@ $sc_style['CPAGENAV|default']['post'] = '';
$PAGE_TEMPLATE['nav']['end'] = '';
- $PAGE_TEMPLATE['nav']['item_active'] = '
-
-
- {LINK_IMAGE} {LINK_NAME}
-
-
- ';
-
- $PAGE_TEMPLATE['nav']['end'] = '';
-
$PAGE_TEMPLATE['nav']['submenu_start'] = '';
@@ -170,6 +160,12 @@ $sc_style['CPAGENAV|default']['post'] = '';
{LINK_SUB}
';
+ $PAGE_TEMPLATE['nav']['submenu_loweritem_active'] = '
+ -
+ {LINK_IMAGE}{LINK_NAME}
+ {LINK_SUB}
+
+ ';
$PAGE_TEMPLATE['nav']['submenu_item_active'] = '
-
diff --git a/e107_handlers/sitelinks_class.php b/e107_handlers/sitelinks_class.php
index 909ea81d6..4099a1d8f 100644
--- a/e107_handlers/sitelinks_class.php
+++ b/e107_handlers/sitelinks_class.php
@@ -1303,7 +1303,7 @@ class e_navigation
foreach ($data as $_data)
{
$sc->setVars($_data);
- $active = ($this->isActive($_data)) ? "_active" : "";
+ $active = ($this->isActive($_data)) ? "_active" : "";
$itemTmpl = count($_data['link_sub']) > 0 ? $template['item_submenu'.$active] : $template['item'.$active];
$ret .= e107::getParser()->parseTemplate($itemTmpl, TRUE);
}
@@ -1343,7 +1343,8 @@ class e_navigation
if($val['link_parent'] == $pid)
{
$val['link_sub'] = $this->isDynamic($val);
- $this->compile($inArray, $val['link_sub'], $val['link_id']);
+ // prevent loop of death
+ if( $val['link_id'] != $pid) $this->compile($inArray, $val['link_sub'], $val['link_id']);
$outArray[] = $val;
}
}
@@ -1471,33 +1472,18 @@ class navigation_shortcodes extends e_shortcode
return;
}
- // XXX possible dead loop if LINK_SUB SC present in submenu_start template
- $text = e107::getParser()->parseTemplate($this->template['submenu_start'], true, $this);
+ $text = e107::getParser()->parseTemplate(str_replace('{LINK_SUB}', '', $this->template['submenu_start']), true, $this);
foreach($this->var['link_sub'] as $val)
{
$this->setVars($val);
- $active = (e107::getNav()->isActive($val)) ? "_active" : "";
- $tmpl = vartrue($val['link_sub']) ? varset($this->template['submenu_loweritem']) : varset($this->template['submenu_item'.$active]);
+ $active = (e107::getNav()->isActive($val)) ? "_active" : "";
+ $tmpl = vartrue($val['link_sub']) ? varset($this->template['submenu_loweritem'.$active]) : varset($this->template['submenu_item'.$active]);
$text .= e107::getParser()->parseTemplate($tmpl, TRUE);
}
- // XXX possible dead loop if LINK_SUB SC present in submenu_end template
- $text .= e107::getParser()->parseTemplate($this->template['submenu_end'], true, $this);
+ $text .= e107::getParser()->parseTemplate(str_replace('{LINK_SUB}', '', $this->template['submenu_end']), true, $this);
return $text;
}
}
-
-
-
-
-
-
-
-
-
-
-
-
-?>
\ No newline at end of file
diff --git a/e107_plugins/page/e_shortcode.php b/e107_plugins/page/e_shortcode.php
index 2429ac61d..b94e71e70 100644
--- a/e107_plugins/page/e_shortcode.php
+++ b/e107_plugins/page/e_shortcode.php
@@ -15,7 +15,7 @@ class page_shortcodes extends e_shortcode
function sc_page_navigation($parm) // TODO when No $parm provided, auto-detect based on URL which book/chapters to display.
{
// FIXME sitelink class should be page_sitelink
- $links = e107::getAddon('page', 'e_sitelink', 'page_sitelink');
+ $links = e107::getAddon('page', 'e_sitelink');
$data = $links->pageNav($parm);
diff --git a/e107_plugins/page/e_sitelink.php b/e107_plugins/page/e_sitelink.php
index 17115489b..274a04758 100644
--- a/e107_plugins/page/e_sitelink.php
+++ b/e107_plugins/page/e_sitelink.php
@@ -40,6 +40,28 @@ class page_sitelink // include plugin-folder in the name.
$sublinks = array();
$arr = array();
+ // map current when in auto mode
+ if(vartrue($options['auto']))
+ {
+ // current book found, top book not set
+ if(vartrue($options['cbook']) && !vartrue($options['book']))
+ {
+ $options['book'] = $options['cbook'];
+ }
+
+ // current chapter found, top chapter not set
+ if(vartrue($options['cchapter']) && !vartrue($options['chapter']))
+ {
+ $options['chapter'] = $options['cchapter'];
+ }
+
+ // current chapter found, top chapter not set
+ if(vartrue($options['cpage']) && !vartrue($options['page']))
+ {
+ $options['page'] = $options['cpage'];
+ }
+ }
+
// find the chapter if required
if(vartrue($options['page']) && !vartrue($options['chapter']))
{
@@ -78,7 +100,7 @@ class page_sitelink // include plugin-folder in the name.
'link_parent' => $row['page_chapter'],
'link_open' => '',
'link_class' => intval($row['page_class']),
- 'link_active' => ($options['page'] && $row['page_id'] == $options['page']),
+ 'link_active' => ($options['cpage'] && $row['page_id'] == $options['cpage']),
);
}
@@ -108,7 +130,6 @@ class page_sitelink // include plugin-folder in the name.
$books = $sql->retrieve("SELECT * FROM #page_chapters WHERE ".$filter." ORDER BY chapter_order ASC" , true);
foreach($books as $row)
{
-
$arr[] = array(
'link_id' => $row['chapter_id'],
'link_name' => $row['chapter_name'],
@@ -124,13 +145,12 @@ class page_sitelink // include plugin-folder in the name.
'link_open' => '',
'link_class' => 0,
'link_sub' => varset($sublinks[$row['chapter_id']]),
- 'link_active' => false,
+ 'link_active' => $row['chapter_parent'] == 0 ? $options['cbook'] && $options['cbook'] == $row['chapter_id'] : $options['cchapter'] && $options['cchapter'] == $row['chapter_id'],
);
- $parent = vartrue($options['book']) ? intval($row['chapter_parent']) : 0;
-
}
$outArray = array();
+ $parent = vartrue($options['book']) ? $options['book'] : 0;
$ret = e107::getNav()->compile($arr, $outArray, $parent);
if(!$title) return $ret;
diff --git a/e107_plugins/page/page_navigation_menu.php b/e107_plugins/page/page_navigation_menu.php
index bbb571f9e..055d66cb9 100644
--- a/e107_plugins/page/page_navigation_menu.php
+++ b/e107_plugins/page/page_navigation_menu.php
@@ -12,33 +12,31 @@ if (!defined('e107_INIT')) { exit; }
$template = e107::getCoreTemplate('page','nav');
-### Auto mode - detect the current location
-if(empty($parm))
+$parm = eHelper::scParams($parm);
+$request = e107::getRegistry('core/pages/request');
+if($request && is_array($request))
{
- $request = e107::getRegistry('core/pages/request');
- $parm = array();
- if($request && is_array($request))
+ switch ($request['action'])
{
- switch ($request['action'])
- {
- case 'listChapters':
- $parm['book'] = $request['id'];
- break;
-
- case 'listPages':
- $parm['chapter'] = $request['id'];
- break;
-
- case 'showPage':
- $parm['page'] = $request['id'];
- break;
- }
+ case 'listChapters':
+ $parm['cbook'] = $request['id'];
+ break;
+
+ case 'listPages':
+ $parm['cchapter'] = $request['id'];
+ break;
+
+ case 'showPage':
+ $parm['cpage'] = $request['id'];
+ break;
}
- if($parm) $parm = http_build_query($parm);
}
+if($parm) $parm = http_build_query($parm, null, '&');
+else $parm = '';
+
### Retrieve
-$links = e107::getAddon('page', 'e_sitelink', 'page_sitelink');
+$links = e107::getAddon('page', 'e_sitelink');
$data = $links->pageNav($parm);
if(isset($data['title']) && !vartrue($template['noAutoTitle']))
{
@@ -46,6 +44,8 @@ if(isset($data['title']) && !vartrue($template['noAutoTitle']))
$template['caption'] = $data['title'];
$data = $data['body'];
}
+
+if(empty($data)) return;
$text = e107::getNav()->render($data, $template) ;
### Render